/// <summary> /// Returns a string array that contains the substrings in this string that are delimited by <see cref="Separators"/>. /// </summary> /// <param name="value">The string to split.</param> /// <param name="targetType">The type of the binding target property. This is not implemented.</param> /// <param name="parameter">The string or strings that delimits the substrings in this string. This overrides the value in <see cref="Separator"/> and <see cref="Separators"/>.</param> /// <param name="culture">The culture to use in the converter. This is not implemented.</param> /// <returns>An array whose elements contain the substrings in this string that are delimited by <see cref="Separator"/> or, if set, <see cref="Separators"/> or, if set, <paramref name="parameter"/>.</returns> public object?Convert(object?value, Type?targetType, object?parameter, CultureInfo?culture) { if (value == null) { return(Enumerable.Empty <string>()); } if (value is not string valueToSplit) { throw new ArgumentException("Value cannot be casted to string", nameof(value)); } if (parameter is string[] separators) { return(Split(valueToSplit, separators)); } if (parameter is string separator) { return(Split(valueToSplit, separator)); } if (parameter != null) { throw new ArgumentException("Parameter cannot be casted to string nor string[]", nameof(parameter)); } if (Separators.Count > 1) { return(Split(valueToSplit, Separators.ToArray())); } return(Split(valueToSplit, Separator)); }
private void SourceCommandLineHandler(DataPackage data) { var command = data.Get <string>(); Tokens = command.Split(Separators.ToArray()); HandleParserStage(command); }
public WordInfo[] GetWordsInfo() { var parseWords = ParseWords(Text, Separators.ToArray()); var distinctWords = GetDistinctWords(parseWords); Words = distinctWords.OfType <DictionaryEntry>() .Select(de => new WordInfo() { Word = de.Key.ToString(), Count = (int)de.Value }) .ToArray(); return(Words); }