/// <summary> /// Executes the step. /// </summary> /// <param name="input">Data to compare against.</param> /// <returns>Data if not prohibited.</returns> /// <exception cref="ProhibitedValueException">Thrown when input is prohibited.</exception> public string Run(string input) { foreach (var value in input.Where(value => _table.Contains(value))) { throw new ProhibitedValueException(value); } return(input); }
public string Run(string input) { for (var i = 0; i < input.Length; i++) { if (_table.Contains(input[i])) { throw new ProhibitedValueException(input[i]); } } return(input); }
/// <summary> /// Run the stringprep step /// </summary> /// <param name="input">Input to run the step on</param> /// <returns>String parsed for unicode characters</returns> public string Run(string input) { var ralProhibited = false; var ralFound = false; var ral = false; var l = false; var first = true; foreach (var c in input) { if (_prohibitedTable.Contains(c)) { throw new ProhibitedValueException(c); } ralFound = _ralTable.Contains(c); ral = ral || ralFound; if (ral && ralProhibited) { throw new BidirectionalFormatException( "A character from the RandAL set was found without the string beginning with an RandAL character"); } l = l || _lTable.Contains(c); if (ral && l) { throw new BidirectionalFormatException("Characters from both the RandAL and L sets were found"); } if (first) { first = false; ralProhibited = !ral; } } if (ral && !ralFound) { throw new BidirectionalFormatException( "A character from the RandAL set must be the last character in an RandAL string"); } return(input); }
/// <summary> /// Does the value have a replacement. /// </summary> /// <param name="value">Value to look for.</param> /// <returns>True if value is in table, otherwise false.</returns> public override bool HasReplacement(int value) { return(_valueRange.Contains(value)); }