System.ComponentModel.MaskedTextProvider.FindAssignedEditPositionFrom C# (CSharp) Method

FindAssignedEditPositionFrom() public method

Gets the position of the first edit char in the test string, the search starts from the specified position included. Returns InvalidIndex if it doesn't find one.
public FindAssignedEditPositionFrom ( int position, bool direction ) : int
position int
direction bool
return int
        public int FindAssignedEditPositionFrom(int position, bool direction)
        {
            if (_assignedCharCount == 0)
            {
                return invalidIndex;
            }

            int startPosition;
            int endPosition;

            if (direction == forward)
            {
                startPosition = position;
                endPosition = _testString.Length - 1;
            }
            else
            {
                startPosition = 0;
                endPosition = position;
            }

            return FindAssignedEditPositionInRange(startPosition, endPosition, direction);
        }

Usage Example

Exemplo n.º 1
0
		public void FindAssignedEditPositionFromTest1 ()
		{
			MaskedTextProvider mtp;
			int Int32_out = 0;
			MaskedTextResultHint MaskedTextResultHint_out = MaskedTextResultHint.Unknown;
			mtp = new MaskedTextProvider (@"abc");
			mtp.Add (@"a");
			mtp.Add ('\x61');
			mtp.Add ('\x61', out Int32_out, out MaskedTextResultHint_out);
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (0, false), "#0");
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (0, true), "#1");
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (1, false), "#2");
			Assert.AreEqual (-1, mtp.FindAssignedEditPositionFrom (1, true), "#3");
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (2, false), "#4");
			Assert.AreEqual (-1, mtp.FindAssignedEditPositionFrom (2, true), "#5");
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (3, false), "#6");
			Assert.AreEqual (-1, mtp.FindAssignedEditPositionFrom (3, true), "#7");
			Assert.AreEqual (0, mtp.FindAssignedEditPositionFrom (4, false), "#8");
			Assert.AreEqual (-1, mtp.FindAssignedEditPositionFrom (4, true), "#9");
			MaskedTextProviderTest.AssertProperties (mtp, "FindAssignedEditPositionFromTest", 10, true, false, 1, 0, CultureInfo.GetCultureInfo ("es-ES"), 1, true, false, false, 0, 3, @"abc", true, true, '\x0', '\x5F', true, true, true, @"abc", @"abc", @"abc", @"abc", @"a", @"abc", @"a");
		}