/// <summary> /// Converts a string to the given attribute's value. /// </summary> /// <param name="attribute">This attribute.</param> /// <param name="value">The value to convert to an attribute value.</param> /// <returns>Returns the attribute's value converted from a string.</returns> /// <exception cref="ArgumentException">If the input string cannot be converted to the attribute's value.</exception> public static object FromString(this DictionaryAttribute attribute, string value) { switch (attribute) { case DictionaryAttribute.Separator: return(Separator.FromString(value)); case DictionaryAttribute.Encoding: return(Encoding.FromString(value)); case DictionaryAttribute.FrequencyIncluded: return(FrequencyIncluded.FromString(value)); case DictionaryAttribute.IgnoreNumbers: return(IgnoreNumbers.FromString(value)); case DictionaryAttribute.IgnorePunctuation: return(IgnorePunctuation.FromString(value)); case DictionaryAttribute.IgnoreCamelCase: return(IgnoreCamelCase.FromString(value)); case DictionaryAttribute.IgnoreAllUpperCase: return(IgnoreAllUpperCase.FromString(value)); case DictionaryAttribute.IgnoreDiacritics: return(IgnoreDiacritics.FromString(value)); case DictionaryAttribute.ConvertCase: return(ConvertCase.FromString(value)); case DictionaryAttribute.RunOnWords: return(RunOnWords.FromString(value)); case DictionaryAttribute.Culture: return(Culture.FromString(value)); case DictionaryAttribute.Encoder: return(Encoder.FromString(value)); case DictionaryAttribute.InputConversion: return(InputConversion.FromString(value)); case DictionaryAttribute.OutputConversion: return(OutputConversion.FromString(value)); case DictionaryAttribute.ReplacementPairs: return(ReplacementPairs.FromString(value)); case DictionaryAttribute.EquivalentChars: return(EquivalentChars.FromString(value)); case DictionaryAttribute.License: return(License.FromString(value)); case DictionaryAttribute.Author: return(Author.FromString(value)); case DictionaryAttribute.CreationDate: return(CreationDate.FromString(value)); } throw new ArgumentException($"No attribute for property: {nameof(attribute)}"); }