/// <summary> /// Method to Validate <see cref="command.hotkey"/> Value /// </summary> /// <returns> /// Returns true if Validation passes; Otherwise, false. /// </returns> protected string ValidateHotkey() { if (string.IsNullOrWhiteSpace(this.hotkey)) { return(Properties.Resources.ErrorValueMutNotBeNull); } HotkeyKeys hks; if (HotkeyKeys.TryParse(this.hotkey, out hks)) { if (Parent != null && Parent.Any( x => string.Equals(x.hotkey, this.hotkey, StringComparison.CurrentCultureIgnoreCase) && !ReferenceEquals(x, this))) { return(Properties.Resources.ErrorDuplicateNotAllowed); } return(string.Empty); } return(Properties.Resources.ErrorInvalidFormat); }
/// <summary> /// Gets error Text of any Property error /// </summary> /// <param name="pName">The Property</param> /// <param name="hasError">True if the property has an error; Otherwise, false</param> /// <returns> /// String containing error message if the property has an error; Otherwise, Empty string. /// </returns> private string GetResult(PropertyNames pName, out bool hasError) { hasError = false; if (pName == PropertyNames.hotkey) { if (string.IsNullOrWhiteSpace(this.hotkey)) { hasError = true; return(Properties.Resources.ErrorValueMutNotBeNull); } HotkeyKeys hks; if (HotkeyKeys.TryParse(this.hotkey, out hks)) { if (Parent != null && Parent.Any( x => string.Equals(x.hotkey, this.hotkey, StringComparison.CurrentCultureIgnoreCase) && !ReferenceEquals(x, this))) { hasError = true; return(Properties.Resources.ErrorDuplicateNotAllowed); } return(string.Empty); } hasError = true; return(Properties.Resources.ErrorInvalidFormat); } else if (pName == PropertyNames.name) { if (string.IsNullOrWhiteSpace(this.name)) { hasError = true; return(Properties.Resources.ErrorValueMutNotBeNull); } } return(string.Empty); }