private void txtIp_KeyPress(object sender, KeyPressEventArgs e) { //txtIp_KeyDown(sender, e); Console.WriteLine("Pressed: " + e.KeyChar); int pos = txtIp.SelectionStart; string orig = txtIp.Text; if (pos < txtIp.Mask.Length && pos < orig.Length && txtIp.Text[pos] == ' ') { MaskedTextResultHint hint = MaskedTextResultHint.DigitExpected; if (txtIp.MaskedTextProvider.VerifyChar(e.KeyChar, pos, out hint)) { if (txtIp.MaskedTextProvider.Replace(e.KeyChar, pos)) { Console.WriteLine(txtIp.MaskedTextProvider.ToDisplayString()); txtIp.MaskedTextProvider.InsertAt(e.KeyChar, pos); } else { Console.WriteLine("Error replacing."); } } else { Console.WriteLine("Hint: " + hint.ToString()); } } }
public static string Format(string mask, string text, out MaskedTextResultHint hint, out int hintPosition, CultureInfo culture = null) { if (text == null) { text = string.Empty; } if (culture == null) { culture = CultureInfo.InvariantCulture; } var provider = new MaskedTextProvider(mask, culture, true); // Format and return the string provider.Set(text, out hintPosition, out hint); // Positive hint results are successful if (hint > 0) { return(provider.ToString()); } // Return the text as-is if it didn't fit the mask return(text); }
private void HandleDeleteByBack() { MaskedTextResultHint resultHint = MaskedTextResultHint.Success; int testPosition = 0; int selectionStart = this.textBoxItem.SelectionStart; int startPosition = this.textBoxItem.SelectionLength == 0 ? selectionStart - 1 : selectionStart; if (startPosition < 0 && this.textBoxItem.SelectionLength == 0) { return; } int endPosition = startPosition + this.textBoxItem.SelectionLength - 1; if (endPosition <= startPosition) { endPosition = startPosition; } if (endPosition >= this.textBoxItem.Text.Length) { endPosition = this.textBoxItem.Text.Length - 1; } this.provider.RemoveAt(startPosition, endPosition, out testPosition, out resultHint); this.textBoxItem.Text = this.provider.ToString(true, true); this.textBoxItem.SelectionLength = 0; this.textBoxItem.SelectionStart = startPosition; }
/// <summary> /// Format the specified text using the specified mask, prompt /// character, and culture information and return the result /// values. /// </summary> /// <param name="mask">The mask to use.</param> /// <param name="text">The text to format.</param> /// <param name="promptChar">The prompt character to use for missing /// characters. If a null character ('\x0') is specified, prompt /// characters are omitted.</param> /// <param name="culture">The culture information to use. If null, /// the current culture is used.</param> /// <param name="hint">The result of formatting the text.</param> /// <param name="hintPosition">The position related to the result /// hint.</param> /// <returns>The formatted text string.</returns> public static string Format(string mask, string text, char promptChar, CultureInfo culture, out MaskedTextResultHint hint, out int hintPosition) { if (text == null) { text = String.Empty; } if (culture == null) { culture = CultureInfo.CurrentCulture; } MaskedTextProvider provider = new MaskedTextProvider(mask, culture); // Set the prompt character options if (promptChar != '\x0') { provider.PromptChar = promptChar; provider.IncludePrompt = true; } // Format and return the string provider.Set(text, out hintPosition, out hint); // Positive hint results are successful if (hint > 0) { return(provider.ToString()); } // Return the text as-is if it didn't fit the mask return(text); }
public bool Validate(string value) { CancelEventArgs e = new CancelEventArgs(); this.owner.CallValueChanging(e); if (e.Cancel) { return(false); } int testPosition = 0; MaskedTextResultHint resultHint = MaskedTextResultHint.Success; if (this.provider.Mask != "<>" && value != null) { this.provider.Set(value.TrimEnd(' '), out testPosition, out resultHint); if (resultHint > MaskedTextResultHint.Unknown) { this.oldValue = this.provider.ToString(true, true); if (this.textBoxItem.Text == this.oldValue) { return(true); } this.textBoxItem.Text = this.oldValue; this.owner.isNullValue = false; this.owner.CallValueChanged(EventArgs.Empty); return(true); } } return(false); }
public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint) { int testPosition1 = 0; testPosition = 0; resultHint = MaskedTextResultHint.NoEffect; foreach (char input1 in input) { if (!this.IsOverwriteMode && this.owner.MaskType != MaskType.IP) { this.provider.InsertAt(input1, testPosition1, out testPosition1, out resultHint); } else { this.provider.Replace(input1, testPosition1, out testPosition1, out resultHint); } if (resultHint > MaskedTextResultHint.Unknown) { ++testPosition1; } } if (testPosition1 > 0) { resultHint = MaskedTextResultHint.Success; } return(true); }
public static string Format( string mask, string text, char promptChar, CultureInfo culture, out MaskedTextResultHint hint, out int hintPosition) { if (text == null) { text = string.Empty; } if (culture == null) { culture = CultureInfo.CurrentCulture; } MaskedTextProvider maskedTextProvider = new MaskedTextProvider(mask, culture); if (promptChar != char.MinValue) { maskedTextProvider.PromptChar = promptChar; maskedTextProvider.IncludePrompt = true; } maskedTextProvider.Set(text, out hintPosition, out hint); if (hint > MaskedTextResultHint.Unknown) { return(maskedTextProvider.ToString()); } return(text); }
public bool Validate(string value) { int testPosition = 0; MaskedTextResultHint resultHint = MaskedTextResultHint.Success; if (this.mask != "<>" && value != null) { this.Set(value, out testPosition, out resultHint); if (resultHint > MaskedTextResultHint.Unknown) { string str = this.ToString(true, true); ValueChangingEventArgs changingEventArgs = new ValueChangingEventArgs((object)str, (object)value); this.owner.CallValueChanging((CancelEventArgs)changingEventArgs); if (changingEventArgs.Cancel) { return(false); } this.textBoxItem.Text = str; this.owner.isNullValue = false; this.owner.CallValueChanged(EventArgs.Empty); return(true); } } return(false); }
public void Ctor_Int_Int_Bool(int position, MaskedTextResultHint rejectionHint) { var e = new MaskInputRejectedEventArgs(position, rejectionHint); Assert.Equal(position, e.Position); Assert.Equal(rejectionHint, e.RejectionHint); }
public void Clear(out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(2)) <= Contract.ValueAtReturn(out resultHint)); Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); resultHint = default(MaskedTextResultHint); }
private string GetRejectionHintText(MaskedTextResultHint hint) { string hintText = string.Empty; switch (hint) { case MaskedTextResultHint.AlphanumericCharacterExpected: hintText = "Invalid character!"; break; case MaskedTextResultHint.DigitExpected: hintText = "Invalid character!"; break; case MaskedTextResultHint.LetterExpected: hintText = "Invalid character!"; break; case MaskedTextResultHint.SignedDigitExpected: hintText = "Invalid character!"; break; //case MaskedTextResultHint.UnavailableEditPosition: // hintText = "Invalid typed character!"; // break; } return(hintText); }
private void HandleDeleteByBack() { MaskedTextResultHint hint = MaskedTextResultHint.Success; int pos = 0; int selectionStart = textBoxItem.SelectionStart; int indexToDelete = textBoxItem.SelectionLength == 0 ? selectionStart - 1 : selectionStart; if (indexToDelete < 0 && textBoxItem.SelectionLength == 0) { return; } int lenToDelete = indexToDelete + textBoxItem.SelectionLength - 1; if (lenToDelete <= indexToDelete) { lenToDelete = indexToDelete + 1; } if (lenToDelete >= this.textBoxItem.Text.Length) { lenToDelete = this.textBoxItem.Text.Length - 1; } this.provider.RemoveAt(indexToDelete, lenToDelete, out pos, out hint); textBoxItem.Text = provider.ToString(true, true); this.textBoxItem.SelectionLength = 0; this.textBoxItem.SelectionStart = indexToDelete; return; }
public bool InsertAt(char input, int position, out int testPosition, out MaskedTextResultHint resultHint) { testPosition = default(int); resultHint = default(MaskedTextResultHint); return(default(bool)); }
public bool Validate(string value) { CancelEventArgs eventArgs = new CancelEventArgs(); this.owner.CallValueChanging(eventArgs); if (eventArgs.Cancel) { return(false); } int hintPos = 0; MaskedTextResultHint hint = MaskedTextResultHint.Success; if (provider.Mask != "<>" && value != null) { provider.Set(value, out hintPos, out hint); // Positive hint results are successful if (hint > 0) { oldValue = provider.ToString(true, true); if (textBoxItem.Text == oldValue) { return(true); } textBoxItem.Text = oldValue; this.owner.CallValueChanged(EventArgs.Empty); return(true); } } //base.Text = unmaskedText; return(false); }
protected virtual string ParseTextCore( string value, out int testPosition, out MaskedTextResultHint resultHint) { testPosition = 0; resultHint = MaskedTextResultHint.Success; string parsedInput = string.Empty; value = this.Replace(value, this.culture.NumberFormat.CurrencySymbol, this.culture.NumberFormat.PercentSymbol); value = value.Trim(); if (string.IsNullOrEmpty(value) || value == this.culture.NumberFormat.NegativeSign) { value = "0"; } value = this.ReplaceGroupSeparator(value); value = this.Replace(value, " "); try { switch (this.numericType) { case NumericCharacterTextBoxProvider.RadNumericMaskFormatType.Currency: bool flag = value.IndexOf("(") > -1; value = this.Replace(value, "(", ")"); value = this.ReplaceCurrencyDecimalSeparatorWithNumberDecimal(value); if (flag && value.IndexOfAny("123456789".ToCharArray()) > -1 && !value.StartsWith(this.culture.NumberFormat.NegativeSign)) { value = this.culture.NumberFormat.NegativeSign + value; } parsedInput = string.Format((IFormatProvider)this.Culture, "{0:" + this.Mask + "}", (object)Decimal.Parse(value, (IFormatProvider)this.Culture)); break; case NumericCharacterTextBoxProvider.RadNumericMaskFormatType.Standard: parsedInput = string.Format((IFormatProvider)this.Culture, "{0:" + this.Mask + "}", (object)(long)Decimal.Parse(value, (IFormatProvider)this.Culture)); break; case NumericCharacterTextBoxProvider.RadNumericMaskFormatType.Percent: this.floatValue = double.Parse(value, (IFormatProvider)this.Culture); this.floatValue /= 100.0; parsedInput = string.Format((IFormatProvider)this.Culture, "{0:" + this.Mask + "}", (object)this.floatValue); break; case NumericCharacterTextBoxProvider.RadNumericMaskFormatType.FixedPoint: parsedInput = string.Format((IFormatProvider)this.Culture, "{0:" + this.Mask + "}", (object)Decimal.Parse(value, (IFormatProvider)this.Culture)); break; case NumericCharacterTextBoxProvider.RadNumericMaskFormatType.Decimal: parsedInput = string.Format((IFormatProvider)this.Culture, "{0:" + this.Mask + "}", (object)Decimal.Parse(value, (IFormatProvider)this.Culture)); break; } parsedInput = this.EnsureMinusSign(value, parsedInput); } catch { resultHint = MaskedTextResultHint.UnavailableEditPosition; } return(parsedInput); }
public bool Add(string input, out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-54)) <= Contract.ValueAtReturn(out resultHint)); testPosition = default(int); resultHint = default(MaskedTextResultHint); return(default(bool)); }
public bool VerifyChar(char input, int position, out MaskedTextResultHint hint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-55)) <= Contract.ValueAtReturn(out hint)); Contract.Ensures(Contract.ValueAtReturn(out hint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); hint = default(MaskedTextResultHint); return(default(bool)); }
public bool Add(string input, out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-54)) <= Contract.ValueAtReturn(out resultHint)); testPosition = default(int); resultHint = default(MaskedTextResultHint); return default(bool); }
public void TestMaskInputRejectedEventArgs() { int pos = 2; MaskedTextResultHint hint = MaskedTextResultHint.InvalidInput; MaskInputRejectedEventArgs e = new MaskInputRejectedEventArgs(pos, hint); Assert.AreEqual(pos, e.Position, "A1"); Assert.AreEqual(hint, e.RejectionHint, "A2"); }
protected virtual string ParseTextCore(string value, out int testPosition, out MaskedTextResultHint resultHint) { testPosition = 0; resultHint = MaskedTextResultHint.Success; string text = ""; if (string.IsNullOrEmpty(value)) { value = "0"; } value = value.Replace(this.culture.NumberFormat.CurrencyGroupSeparator, ""); try { switch (this.numericType) { case RadNumericMaskFormatType.None: break; case RadNumericMaskFormatType.Currency: value = value.Replace(this.culture.NumberFormat.CurrencySymbol, ""); text = String.Format(this.Culture, "{0:" + this.Mask + "}", Decimal.Parse(value, this.Culture)); break; case RadNumericMaskFormatType.Standard: text = String.Format(this.Culture, "{0:" + this.Mask + "}", (Int64)Decimal.Parse(value, this.Culture)); break; case RadNumericMaskFormatType.Percent: double floatValue = double.Parse(value.Replace("%", ""), this.Culture); floatValue /= 100; text = String.Format(this.Culture, "{0:" + this.Mask + "}", floatValue); break; case RadNumericMaskFormatType.FixedPoint: text = String.Format(this.Culture, "{0:" + this.Mask + "}", Decimal.Parse(value, this.Culture)); break; case RadNumericMaskFormatType.Decimal: text = String.Format(this.Culture, "{0:" + this.Mask + "}", Decimal.Parse(value, this.Culture)); break; default: break; } } catch { resultHint = MaskedTextResultHint.UnavailableEditPosition; } return(text); }
public bool Remove(out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(2)) <= Contract.ValueAtReturn(out resultHint)); Contract.Ensures(0 <= Contract.ValueAtReturn(out testPosition)); Contract.Ensures(Contract.Result <bool>() == true); Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); testPosition = default(int); resultHint = default(MaskedTextResultHint); return(default(bool)); }
private void HandleDeleteByDel() { MaskedTextResultHint hint = MaskedTextResultHint.Success; int selectionStart = textBoxItem.SelectionStart; int selectionLen = textBoxItem.SelectionLength; int indexToDelete = selectionStart; int pos = indexToDelete; this.provider.RemoveAt(indexToDelete, indexToDelete + (selectionLen > 0?selectionLen - 1:0), out pos, out hint); textBoxItem.Text = provider.ToString(true, true); this.textBoxItem.SelectionLength = 0; this.textBoxItem.SelectionStart = indexToDelete; return; }
public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint) { resultHint = MaskedTextResultHint.Success; testPosition = 0; string textCore = this.ParseTextCore(input, out testPosition, out resultHint); if (resultHint != MaskedTextResultHint.Success) { return(false); } this.value = textCore; this.textBoxItem.Text = textCore; return(true); }
public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint) { resultHint = MaskedTextResultHint.Success; testPosition = 0; string returnString = this.ParseTextCore(input, out testPosition, out resultHint); if (resultHint == MaskedTextResultHint.Success) { this.value = returnString; return(true); } return(false); }
private void HandleDeleteByDel() { MaskedTextResultHint resultHint = MaskedTextResultHint.Success; int selectionStart = this.textBoxItem.SelectionStart; int selectionLength = this.textBoxItem.SelectionLength; int startPosition = selectionStart; int testPosition = startPosition; if (this.owner.MaskType == MaskType.IP) { if (selectionLength == 0 || selectionLength == this.textBoxItem.Text.Length) { this.provider.Replace(' ', startPosition, startPosition + (selectionLength > 0 ? selectionLength - 1 : 0), out testPosition, out resultHint); ++startPosition; } else { int num = 0; string input = this.textBoxItem.Text; for (int startIndex = startPosition; startIndex < startPosition + selectionLength; ++startIndex) { input = input.Remove(startIndex, 1).Insert(startIndex, this.PromptChar.ToString()); ++num; } startPosition += num; this.provider.Set(input); } } else { this.provider.RemoveAt(startPosition, startPosition + (selectionLength > 0 ? selectionLength - 1 : 0), out testPosition, out resultHint); } this.textBoxItem.Text = this.provider.ToString(true, true); this.textBoxItem.SelectionLength = 0; this.textBoxItem.SelectionStart = startPosition; }
public MaskInputRejectedEventArgs (int position, MaskedTextResultHint rejectionHint) : base () { this.position = position; this.rejection_hint = rejectionHint; }
void PostprocessKeyboardInput (bool result, int newPosition, int testPosition, MaskedTextResultHint resultHint) { if (!result) OnMaskInputRejected (new MaskInputRejectedEventArgs (testPosition, resultHint)); else { if (newPosition != MaskedTextProvider.InvalidIndex) SelectionStart = newPosition; else SelectionStart = provider.Length; UpdateVisibleText (); } }
public MaskInputRejectedEventArgs(int position, MaskedTextResultHint rejectionHint) : base() { this.position = position; this.rejection_hint = rejectionHint; }
public bool VerifyChar(char input, int position, out MaskedTextResultHint hint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-55)) <= Contract.ValueAtReturn(out hint)); Contract.Ensures(Contract.ValueAtReturn(out hint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); hint = default(MaskedTextResultHint); return default(bool); }
public bool Remove(out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(2)) <= Contract.ValueAtReturn(out resultHint)); Contract.Ensures(0 <= Contract.ValueAtReturn(out testPosition)); Contract.Ensures(Contract.Result<bool>() == true); Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); testPosition = default(int); resultHint = default(MaskedTextResultHint); return default(bool); }
public static bool GetOperationResultFromHint(MaskedTextResultHint hint) { Contract.Ensures(Contract.Result<bool>() == (hint > ((System.ComponentModel.MaskedTextResultHint)(0)))); return default(bool); }
/// <devdoc> /// Attempts to insert the characters in the specified string in at the specified position in the test string, /// shifting characters at upper positions (if any) to make room for the input. /// It performs the insertion if the testOnly parameter is false and the test passes. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool InsertAtInt(string input, int position, out int testPosition, out MaskedTextResultHint resultHint, bool testOnly) { Debug.Assert(input != null && position >= 0 && position < this.testString.Length, "input param out of range."); if (input.Length == 0) // nothing to insert. { testPosition = position; resultHint = MaskedTextResultHint.NoEffect; return true; } // Test input string first. testPosition will containt the position of the last inserting character from the input. if (!TestString(input, position, out testPosition, out resultHint)) { return false; } // Now check if we need to open room for the input characters (shift characters right) and if so test the shifting characters. int srcPos = FindEditPositionFrom(position, forward); // source position. bool shiftNeeded = FindAssignedEditPositionInRange(srcPos, testPosition, forward) != invalidIndex; int lastAssignedPos = this.LastAssignedPosition; if( shiftNeeded && (testPosition == this.testString.Length - 1)) // no room for shifting. { resultHint = MaskedTextResultHint.UnavailableEditPosition; testPosition = this.testString.Length; return false; } int dstPos = FindEditPositionFrom(testPosition + 1, forward); // destination position. if (shiftNeeded) { // Temp hint used not to overwrite the primary operation result hint (from TestString). MaskedTextResultHint tempHint = MaskedTextResultHint.Unknown; // Test shifting characters. while (true) { if (dstPos == invalidIndex) { resultHint = MaskedTextResultHint.UnavailableEditPosition; testPosition = this.testString.Length; return false; } CharDescriptor chDex = this.stringDescriptor[srcPos]; if (chDex.IsAssigned) // only test assigned positions. { if (!TestChar(this.testString[srcPos], dstPos, out tempHint)) { resultHint = tempHint; testPosition = dstPos; return false; } } if (srcPos == lastAssignedPos) // all shifting positions tested? { break; } srcPos = FindEditPositionFrom(srcPos + 1, forward); dstPos = FindEditPositionFrom(dstPos + 1, forward); } if (tempHint > resultHint) { resultHint = tempHint; } } if (testOnly) { return true; // test done! } // Tests passed so we can go ahead and shift the existing characters (if needed) and insert the new ones. if (shiftNeeded) { while (srcPos >= position) { CharDescriptor chDex = this.stringDescriptor[srcPos]; if (chDex.IsAssigned) { SetChar(this.testString[srcPos], dstPos); } else { ResetChar(dstPos); } dstPos = FindEditPositionFrom(dstPos - 1, backward); srcPos = FindEditPositionFrom(srcPos - 1, backward); } } // Finally set the input characters. SetString(input, position); return true; }
/// <devdoc> /// Replaces the character at the first edit position from the one specified with the first character in the input; /// the rest of the characters in the input will be placed in the test string according to the InsertMode (insert/replace), /// shifting characters at upper positions (if any) to make room for the entire input. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool Replace(string input, int position, out int testPosition, out MaskedTextResultHint resultHint) { if (input == null) { throw new ArgumentNullException("input"); } if (position < 0 || position >= this.testString.Length) { testPosition = position; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("position"); } if (input.Length == 0) // remove the character at position. { return RemoveAt(position, position, out testPosition, out resultHint ); } // At this point, we are replacing characters with the ones in the input. if (!TestSetString(input, position, out testPosition, out resultHint)) { return false; } return true; }
/// <devdoc> /// Replaces the first editable character in the test string from the specified position, with the specified /// character and removes any remaining characters in the range unless the character at the specified position /// is to be escaped. /// If specified range covers more than one assigned edit character, shift-left is performed after replacing /// the first character. This is useful when in a edit box the user selects text and types a character to replace it. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool Replace(char input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint) { if (endPosition >= this.testString.Length) { testPosition = endPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("endPosition"); } if (startPosition < 0 || startPosition > endPosition) { testPosition = startPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("startPosition"); } if (startPosition == endPosition) { testPosition = startPosition; return TestSetChar(input, startPosition, out resultHint); } return Replace( input.ToString(), startPosition, endPosition, out testPosition, out resultHint ); }
public bool Replace(string input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-55)) <= Contract.ValueAtReturn(out resultHint)); Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); testPosition = default(int); resultHint = default(MaskedTextResultHint); return(default(bool)); }
/// <devdoc> /// Removes all characters in edit position from in the test string at the specified start and end positions /// and shifts any remaining characters left. /// If testOnly parameter is set to false and the test passes it performs the operations on the characters. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool RemoveAtInt(int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint, bool testOnly) { Debug.Assert(startPosition >= 0 && startPosition <= endPosition && endPosition < this.testString.Length, "Out of range input value."); // Check if we need to shift characters left to occupied the positions left by the characters being removed. int lastAssignedPos = this.LastAssignedPosition; int dstPos = FindEditPositionInRange(startPosition, endPosition, forward); // first edit position in range. resultHint = MaskedTextResultHint.NoEffect; if (dstPos == invalidIndex || dstPos > lastAssignedPos) // nothing to remove. { testPosition = startPosition; return true; } testPosition = startPosition; // On remove range, testPosition remains the same as startPosition. bool shiftNeeded = endPosition < lastAssignedPos; // last assigned position is upper. // if there are assigned characters to be removed (could be that the range doesn't have one, in such case we may be just // be shifting chars), the result hint is success, let's check. if (FindAssignedEditPositionInRange(startPosition, endPosition, forward) != invalidIndex) { resultHint = MaskedTextResultHint.Success; } if (shiftNeeded) { // Test shifting characters. int srcPos = FindEditPositionFrom(endPosition + 1, forward); // first position to shift left. int shiftStart = srcPos; // cache it here so we don't have to search for it later if needed. MaskedTextResultHint testHint; startPosition = dstPos; // actual start position. while(true) { char srcCh = this.testString[srcPos]; CharDescriptor chDex = this.stringDescriptor[srcPos]; // if the shifting character is the prompt and it is at an unassigned position we don't need to test it. if (srcCh != this.PromptChar || chDex.IsAssigned) { if (!TestChar(srcCh, dstPos, out testHint)) { resultHint = testHint; testPosition = dstPos; // failed position. return false; } } if (srcPos == lastAssignedPos) { break; } srcPos = FindEditPositionFrom( srcPos + 1, forward); dstPos = FindEditPositionFrom( dstPos + 1, forward); } // shifting characters is a resultHint == sideEffect, update hint if no characters removed (which would be hint == success). if( MaskedTextResultHint.SideEffect > resultHint ) { resultHint = MaskedTextResultHint.SideEffect; } if (testOnly) { return true; // test completed. } // test passed so shift characters. srcPos = shiftStart; dstPos = startPosition; while(true) { char srcCh = this.testString[srcPos]; CharDescriptor chDex = this.stringDescriptor[srcPos]; // if the shifting character is the prompt and it is at an unassigned position we just reset the destination position. if (srcCh == this.PromptChar && !chDex.IsAssigned) { ResetChar(dstPos); } else { SetChar(srcCh, dstPos); ResetChar( srcPos ); } if (srcPos == lastAssignedPos) { break; } srcPos = FindEditPositionFrom( srcPos + 1, forward ); dstPos = FindEditPositionFrom( dstPos + 1, forward ); } // If shifting character are less than characters to remove in the range, we need to remove the remaining ones in the range; // update startPosition and ResetString belwo will take care of that. startPosition = dstPos + 1; } if( startPosition <= endPosition ) { ResetString(startPosition, endPosition); } return true; }
/// <devdoc> /// Removes all characters in edit position from in the test string at the specified start and end positions /// and shifts any remaining characters left. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool RemoveAt(int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint) { if (endPosition >= this.testString.Length) { testPosition = endPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("endPosition"); } if (startPosition < 0 || startPosition > endPosition) { testPosition = startPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("startPosition"); } return RemoveAtInt(startPosition, endPosition, out testPosition, out resultHint, /*testOnly*/ false); }
/// <devdoc> /// Removes the last character from the formatted string. (Remove last character in virtual string). /// On exit the out param contains the position where the operation was actually performed. /// This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool Remove(out int testPosition, out MaskedTextResultHint resultHint) { int lastAssignedPos = this.LastAssignedPosition; if (lastAssignedPos == invalidIndex) { testPosition = 0; resultHint = MaskedTextResultHint.NoEffect; return true; // nothing to remove. } ResetChar(lastAssignedPos); testPosition = lastAssignedPos; resultHint = MaskedTextResultHint.Success; return true; }
/// <devdoc> /// Override version to be able to perform the operation on a cloned provider. /// </devdoc> private bool PlaceChar(MaskedTextProvider provider, char ch, int startPosition, int length, bool overwrite, out MaskedTextResultHint hint) { Debug.Assert( !this.flagState[IS_NULL_MASK], "This method must be called when a Mask is provided." ); this.caretTestPos = startPosition; if (startPosition < this.maskedTextProvider.Length) { if (length > 0) // Replacing selection with input char. { int endPos = startPosition + length - 1; return provider.Replace(ch, startPosition, endPos, out this.caretTestPos, out hint); } else { if (overwrite) { // overwrite character at next edit position from startPosition (inclusive). return provider.Replace(ch, startPosition, out this.caretTestPos, out hint); } else // insert. { return provider.InsertAt(ch, startPosition, out this.caretTestPos, out hint); } } } hint = MaskedTextResultHint.UnavailableEditPosition; return false; }
/// <devdoc> /// Replaces the characters in the specified range with the characters in the input string and shifts /// characters appropriately (removing or inserting characters according to whether the input string is /// shorter or larger than the specified range. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool Replace(string input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint) { if (input == null) { throw new ArgumentNullException("input"); } if (endPosition >= this.testString.Length) { testPosition = endPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("endPosition"); } if (startPosition < 0 || startPosition > endPosition) { testPosition = startPosition; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("startPosition"); } if (input.Length == 0) // remove character at position. { return RemoveAt( startPosition, endPosition, out testPosition, out resultHint ); } // If replacing the entire text with a same-lenght text, we are just setting (not replacing) the test string to the new value; // in this case we just call SetString. // If the text length is different than the specified range we would need to remove or insert characters; there are three possible // cases as follows: // 1. The text length is the same as edit positions in the range (or no assigned chars): just replace the text, no additional operations needed. // 2. The text is shorter: replace the text in the text string and remove (range - text.Length) characters. // 3. The text is larger: replace range count characters and insert (range - text.Length) characters. // Test input string first and get the last test position to determine what to do. if( !TestString( input, startPosition, out testPosition, out resultHint )) { return false; } if (this.assignedCharCount > 0) { // cache out params to preserve the ones from the primary operation (in case of success). int tempPos; MaskedTextResultHint tempHint; if (testPosition < endPosition) // Case 2. Replace + Remove. { // Test removing remaining characters. if (!RemoveAtInt(testPosition + 1, endPosition, out tempPos, out tempHint, /*testOnly*/ false)) { testPosition = tempPos; resultHint = tempHint; return false; } // If current result hint is not success (no effect), and character shifting is actually performed, hint = side effect. if (tempHint == MaskedTextResultHint.Success && resultHint != tempHint) { resultHint = MaskedTextResultHint.SideEffect; } } else if (testPosition > endPosition) // Case 3. Replace + Insert. { // Test shifting existing characters to make room for inserting part of the input. int lastAssignedPos = this.LastAssignedPosition; int dstPos = testPosition + 1; int srcPos = endPosition + 1; while (true) { srcPos = FindEditPositionFrom(srcPos, forward); dstPos = FindEditPositionFrom(dstPos, forward); if (dstPos == invalidIndex) { testPosition = this.testString.Length; resultHint = MaskedTextResultHint.UnavailableEditPosition; return false; } if (!TestChar(this.testString[srcPos], dstPos, out tempHint)) { testPosition = dstPos; resultHint = tempHint; return false; } // If current result hint is not success (no effect), and character shifting is actually performed, hint = success effect. if (tempHint == MaskedTextResultHint.Success && resultHint != tempHint) { resultHint = MaskedTextResultHint.Success; } if (srcPos == lastAssignedPos) { break; } srcPos++; dstPos++; } // shift test passed, now do it. while (dstPos > testPosition) { SetChar(this.testString[srcPos], dstPos); srcPos = FindEditPositionFrom(srcPos - 1, backward); dstPos = FindEditPositionFrom(dstPos - 1, backward); } } // else endPosition == testPosition, this means replacing the entire text which is the same as Set(). } // in all cases we need to replace the input. SetString( input, startPosition ); return true; }
/// <devdoc> /// Sets the edit characters in the test string to the ones specified in the input string if all characters /// are valid. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// If passwordChar is assigned, it is rendered in the output string instead of the user-supplied values. /// </devdoc> public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint) { if (input == null) { throw new ArgumentNullException("input"); } resultHint = MaskedTextResultHint.Unknown; testPosition = 0; if (input.Length == 0) // Clearing the input text. { Clear(out resultHint); return true; } if (!TestSetString(input, testPosition, out testPosition, out resultHint)) { return false; } // Reset remaining characters (if any). int resetPos = FindAssignedEditPositionFrom(testPosition + 1, forward); if (resetPos != invalidIndex) { ResetString(resetPos, this.testString.Length - 1); } return true; }
/// <devdoc> /// Resets the state of the test string edit chars. (Remove all characters from the virtual string). /// The MaskedTextResultHint out param gives more information about the operation result. /// </devdoc> public void Clear( out MaskedTextResultHint resultHint ) { if (this.assignedCharCount == 0) { resultHint = MaskedTextResultHint.NoEffect; return; } resultHint = MaskedTextResultHint.Success; for( int position = 0; position < this.testString.Length; position++ ) { ResetChar( position ); } }
/// <devdoc> /// Tests whether the character at the specified position in the test string can be set to the specified /// value. /// The position specified is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool TestChar(char input, int position, out MaskedTextResultHint resultHint) { // boundary checks are performed in the public methods. Debug.Assert(position >= 0 && position < this.testString.Length, "Position out of range."); if (!IsPrintableChar(input)) { resultHint = MaskedTextResultHint.InvalidInput; return false; } // Get the character info from the char descriptor table. CharDescriptor charDex = this.stringDescriptor[position]; // Test if character should be escaped. // Test literals first - See VSW#454461. See commented-out method SynchronizeInputOptions() if (IsLiteralPosition(charDex)) { if (this.SkipLiterals && (input == this.testString[position])) { resultHint = MaskedTextResultHint.CharacterEscaped; return true; } resultHint = MaskedTextResultHint.NonEditPosition; return false; } if (input == this.promptChar ) { if( this.ResetOnPrompt ) { if (IsEditPosition(charDex) && charDex.IsAssigned) // Position would be reset. { resultHint = MaskedTextResultHint.SideEffect; } else { resultHint = MaskedTextResultHint.CharacterEscaped; } return true; // test does not fail for prompt when it is to be scaped. } // Escaping precedes AllowPromptAsInput. Now test for it. if( !this.AllowPromptAsInput ) { resultHint = MaskedTextResultHint.PromptCharNotAllowed; return false; } } if( input == spaceChar && this.ResetOnSpace ) { if( IsEditPosition(charDex) && charDex.IsAssigned ) // Position would be reset. { resultHint = MaskedTextResultHint.SideEffect; } else { resultHint = MaskedTextResultHint.CharacterEscaped; } return true; } // Character was not escaped, now test it against the mask. // Test the character against the mask constraints. The switch tests false conditions. // Space char succeeds the test if the char type is optional. switch (this.mask[charDex.MaskPosition]) { case '#': // digit or plus/minus sign optional. if (!Char.IsDigit(input) && (input != '-') && (input != '+') && input != spaceChar) { resultHint = MaskedTextResultHint.DigitExpected; return false; } break; case '0': // digit required. if (!Char.IsDigit(input)) { resultHint = MaskedTextResultHint.DigitExpected; return false; } break; case '9': // digit optional. if (!Char.IsDigit(input) && input != spaceChar) { resultHint = MaskedTextResultHint.DigitExpected; return false; } break; case 'L': // letter required. if (!Char.IsLetter(input)) { resultHint = MaskedTextResultHint.LetterExpected; return false; } if (!IsAsciiLetter(input) && this.AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; case '?': // letter optional. if (!Char.IsLetter(input) && input != spaceChar) { resultHint = MaskedTextResultHint.LetterExpected; return false; } if (!IsAsciiLetter(input) && this.AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; case '&': // any character required. if (!IsAscii(input) && this.AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; case 'C': // any character optional. if ((!IsAscii(input) && this.AsciiOnly) && input != spaceChar) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; case 'A': // Alphanumeric required. if (!IsAlphanumeric(input)) { resultHint = MaskedTextResultHint.AlphanumericCharacterExpected; return false; } if (!IsAciiAlphanumeric(input) && this.AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; case 'a': // Alphanumeric optional. if (!IsAlphanumeric(input) && input != spaceChar) { resultHint = MaskedTextResultHint.AlphanumericCharacterExpected; return false; } if (!IsAciiAlphanumeric(input) && this.AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; } break; default: Debug.Fail("Invalid mask language character."); break; } // Test passed. if (input == this.testString[position] && charDex.IsAssigned) // setting char would not make any difference { resultHint = MaskedTextResultHint.NoEffect; } else { resultHint = MaskedTextResultHint.Success; } return true; }
public bool InsertAt(char input, int position, out int testPosition, out MaskedTextResultHint resultHint) { testPosition = default(int); resultHint = default(MaskedTextResultHint); return default(bool); }
/// <devdoc> /// Tests if the character at the specified position in the test string can be set to the value specified, /// and sets the character to that value if the test is successful. /// The position specified is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool TestSetChar(char input, int position, out MaskedTextResultHint resultHint) { if (TestChar(input, position, out resultHint)) { if( resultHint == MaskedTextResultHint.Success || resultHint == MaskedTextResultHint.SideEffect ) // the character is not to be escaped. { SetChar(input, position); } return true; } return false; }
public bool Replace(string input, int startPosition, int endPosition, out int testPosition, out MaskedTextResultHint resultHint) { Contract.Ensures(((System.ComponentModel.MaskedTextResultHint)(-55)) <= Contract.ValueAtReturn(out resultHint)); Contract.Ensures(Contract.ValueAtReturn(out resultHint) <= ((System.ComponentModel.MaskedTextResultHint)(4))); testPosition = default(int); resultHint = default(MaskedTextResultHint); return default(bool); }
/// <devdoc> /// Test the characters in the specified string agaist the test string, starting from the specified position. /// If the test is successful, the characters in the test string are set appropriately. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool TestSetString(string input, int position, out int testPosition, out MaskedTextResultHint resultHint) { if (TestString(input, position, out testPosition, out resultHint)) { SetString(input, position); return true; } return false; }
public static bool GetOperationResultFromHint(MaskedTextResultHint hint) { Contract.Ensures(Contract.Result <bool>() == (hint > ((System.ComponentModel.MaskedTextResultHint)(0)))); return(default(bool)); }
/// <devdoc> /// Test the characters in the specified string agaist the test string, starting from the specified position. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The successCount out param contains the number of characters that would be actually set (not escaped). /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> private bool TestString(string input, int position, out int testPosition, out MaskedTextResultHint resultHint) { Debug.Assert(input != null, "null input."); Debug.Assert( position >= 0, "Position out of range." ); resultHint = MaskedTextResultHint.Unknown; testPosition = position; if( input.Length == 0 ) { return true; } // If any char is actually accepted, then the hint is success, otherwise whatever the last character result is. // Need a temp variable for this. MaskedTextResultHint tempHint = resultHint; foreach( char ch in input ) { if( testPosition >= this.testString.Length ) { resultHint = MaskedTextResultHint.UnavailableEditPosition; return false; } // If character is not to be escaped, we need to find an edit position to test it in. if( !TestEscapeChar(ch, testPosition) ) { testPosition = FindEditPositionFrom( testPosition, forward ); if( testPosition == invalidIndex ) { testPosition = this.testString.Length; resultHint = MaskedTextResultHint.UnavailableEditPosition; return false; } } // Test/Set char will scape prompt, space and literals if needed. if( !TestChar( ch, testPosition, out tempHint ) ) { resultHint = tempHint; return false; } // Result precedence: Success, SideEffect, NoEffect, CharacterEscaped. if( tempHint > resultHint ) { resultHint = tempHint; } testPosition++; } testPosition--; return true; }
public MaskInputRejectedEventArgs(int position, MaskedTextResultHint rejectionHint) { Debug.Assert(!MaskedTextProvider.GetOperationResultFromHint(rejectionHint), "Rejection hint is not on a failure."); this.position = position; this.hint = rejectionHint; }
/// <devdoc> /// Tests whether the specified character would be set successfully at the specified position. /// </devdoc> public bool VerifyChar(char input, int position, out MaskedTextResultHint hint) { hint = MaskedTextResultHint.NoEffect; if (position < 0 || position >= this.testString.Length) { hint = MaskedTextResultHint.PositionOutOfRange; return false; } return TestChar(input, position, out hint); }
private void ShowError(Label label, StackLayout stacklayout, RowDefinition row, MaskedTextResultHint hint) { string hintText = GetRejectionHintText(hint); if (!string.IsNullOrEmpty(hintText)) { stacklayout.IsVisible = true; label.IsVisible = true; label.Text = hintText; row.Height = new GridLength(1, GridUnitType.Auto); } }
/// <devdoc> /// Verifies the test string against the mask. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool VerifyString(string input, out int testPosition, out MaskedTextResultHint resultHint) { testPosition = 0; if( input == null || input.Length == 0 ) // nothing to verify. { resultHint = MaskedTextResultHint.NoEffect; return true; } return TestString(input, 0, out testPosition, out resultHint); }
/// <devdoc> /// Insert or replaces the specified character into the control's text and updates the caret position. /// If overwrite is true, it replaces the character at the selection start position. /// </devdoc> private bool PlaceChar(char ch, int startPosition, int length, bool overwrite, out MaskedTextResultHint hint) { return PlaceChar(this.maskedTextProvider, ch, startPosition, length, overwrite, out hint ); }
/// <devdoc> /// Attempts to add the specified charactert to the last unoccupied positions in the test string (append text to /// the virtual string). /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives a hint about the operation result reason. /// Returns true on success, false otherwise. /// </devdoc> public bool Add( char input, out int testPosition, out MaskedTextResultHint resultHint ) { int lastAssignedPos = this.LastAssignedPosition; if( lastAssignedPos == this.testString.Length - 1 ) // at the last edit char position. { testPosition = this.testString.Length; resultHint = MaskedTextResultHint.UnavailableEditPosition; return false; } // Get position after last assigned position. testPosition = lastAssignedPos + 1; testPosition = FindEditPositionFrom( testPosition, forward ); if( testPosition == invalidIndex ) { resultHint = MaskedTextResultHint.UnavailableEditPosition; testPosition = this.testString.Length; return false; } if( !TestSetChar( input, testPosition, out resultHint ) ) { return false; } return true; }
public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint) { return(this.provider.Set(input, out testPosition, out resultHint)); }
/// <devdoc> /// Attempts to add the characters in the specified string to the last unoccupied positions in the test string /// (append text to the virtual string). /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives a hint about the operation result reason. /// Returns true on success, false otherwise. /// </devdoc> public bool Add( string input, out int testPosition, out MaskedTextResultHint resultHint ) { if( input == null ) { throw new ArgumentNullException( "input" ); } testPosition = this.LastAssignedPosition + 1; if( input.Length == 0 ) // nothing to add. { // Get position where the test would be performed. resultHint = MaskedTextResultHint.NoEffect; return true; } return TestSetString(input, testPosition, out testPosition, out resultHint); }
/// <devdoc> /// Replaces the first editable character in the test string from the specified position, with the specified /// character, unless the character at the specified position is to be escaped. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool Replace(char input, int position, out int testPosition, out MaskedTextResultHint resultHint) { if (position < 0 || position >= this.testString.Length) { testPosition = position; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("position"); } testPosition = position; // If character is not to be escaped, we need to find the first edit position to test it in. if (!TestEscapeChar( input, testPosition )) { testPosition = FindEditPositionFrom( testPosition, forward ); } if (testPosition == invalidIndex) { resultHint = MaskedTextResultHint.UnavailableEditPosition; testPosition = position; return false; } if (!TestSetChar(input, testPosition, out resultHint)) { return false; } return true; }
/// <devdoc> /// Attempts to insert the characters in the specified string in at the specified position in the test string, /// shifting characters at upper positions (if any) to make room for the input. /// On exit the testPosition contains last position where the primary operation was actually performed if successful, /// otherwise the first position that made the test fail. This position is relative to the test string. /// The MaskedTextResultHint out param gives more information about the operation result. /// Returns true on success, false otherwise. /// </devdoc> public bool InsertAt(string input, int position, out int testPosition, out MaskedTextResultHint resultHint) { if (input == null) { throw new ArgumentNullException("input"); } if (position < 0 || position >= this.testString.Length) { testPosition = position; resultHint = MaskedTextResultHint.PositionOutOfRange; return false; //throw new ArgumentOutOfRangeException("position"); } return InsertAtInt(input, position, out testPosition, out resultHint, false); }