/// <summary> /// Initializes a new instance of the <see cref="CharacterFormat"/> class. /// </summary> /// <param name="characterCasing">The character casing.</param> /// <param name="removeSpace">The remove multiple spaces.</param> /// <exception cref="InvalidEnumArgumentException">characterCasing is not a member of CharacterCasing enum.</exception> /// <exception cref="InvalidEnumArgumentException">removeSpace is not a member of RemoveSpace enum.</exception> public CharacterFormat(CharacterCasing characterCasing, RemoveSpace removeSpace) { if (!Enum.IsDefined(typeof(CharacterCasing), characterCasing)) { throw new InvalidEnumArgumentException(nameof(characterCasing), (Int32)characterCasing, typeof(CharacterCasing)); } if (!Enum.IsDefined(typeof(RemoveSpace), removeSpace)) { throw new InvalidEnumArgumentException(nameof(removeSpace), (Int32)removeSpace, typeof(RemoveSpace)); } this.CharacterCasing = characterCasing; this.RemoveSpace = removeSpace; }
/// <summary> /// Adds a CharacterCasing Formatting rule to the list of rules to be executed when the property is changed. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="characterCasing">The desired character casing formatting.</param> /// <param name="removeSpace">The remove multiple space.</param> /// <exception cref="ArgumentException">propertyName cannot be null or whitespace.</exception> /// <exception cref="InvalidEnumArgumentException">characterCasing is not a member of CharacterCasing enum.</exception> /// <exception cref="InvalidEnumArgumentException">characterCasing is not a member of CharacterCasing enum.</exception> public void AddRule(String propertyName, CharacterCasing characterCasing, RemoveSpace removeSpace) { if (string.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentException("Value cannot be null or white space.", nameof(propertyName)); } if (!Enum.IsDefined(typeof(CharacterCasing), characterCasing)) { throw new InvalidEnumArgumentException(nameof(characterCasing), (Int32)characterCasing, typeof(CharacterCasing)); } if (!Enum.IsDefined(typeof(RemoveSpace), removeSpace)) { throw new InvalidEnumArgumentException(nameof(removeSpace), (Int32)removeSpace, typeof(RemoveSpace)); } this.RulesDictionary.Add(propertyName, new CharacterFormat(characterCasing, removeSpace)); }
/// <summary>Adds a CharacterCasing Formatting rule to the list of rules to be executed when the property is changed.</summary> /// <param name="propertyName">Name of the property.</param> /// <param name="characterCasing">The desired character casing formatting.</param> /// <param name="removeSpace">The remove multiple space.</param> /// <param name="phoneExtension">The phone extension.</param> /// <exception cref="ArgumentNullEmptyWhiteSpaceException">Thrown when propertyName is null, empty, or white space.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when enum value characterCasing is not defined.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when enum value removeSpace is not defined.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when enum value phoneExtension is not defined.</exception> public void AddRule(String propertyName, CharacterCasing characterCasing, RemoveSpace removeSpace, PhoneExtension phoneExtension) { if (String.IsNullOrWhiteSpace(propertyName)) { throw new ArgumentNullEmptyWhiteSpaceException(nameof(propertyName)); } if (!Enum.IsDefined(typeof(CharacterCasing), characterCasing)) { throw new InvalidEnumArgumentException(nameof(characterCasing), (Int32)characterCasing, typeof(CharacterCasing)); } if (!Enum.IsDefined(typeof(RemoveSpace), removeSpace)) { throw new InvalidEnumArgumentException(nameof(removeSpace), (Int32)removeSpace, typeof(RemoveSpace)); } if (!Enum.IsDefined(typeof(PhoneExtension), phoneExtension)) { throw new InvalidEnumArgumentException(nameof(phoneExtension), (Int32)phoneExtension, typeof(PhoneExtension)); } this.RulesDictionary.Add(propertyName, new CharacterFormat(characterCasing, removeSpace, phoneExtension)); }