/// <summary> /// 根据规则类型得到规则信息 /// </summary> /// <param name="regexDefault"></param> /// <returns></returns> public string GetRegexRule(RegexDefault regexDefault) { if (_rules.Any(x => x.Key.Equals(regexDefault))) { return(_rules.Where(x => x.Key.Equals(regexDefault)).Select(x => x.Value).FirstOrDefault()); } throw new ArgumentNullException("rule regex"); }
/// <summary> /// Determines whether the specified <see cref="PostalCodes.PostalCodeFormat"/> is equal to the current <see cref="PostalCodes.PostalCodeFormat"/>. /// </summary> /// <param name="other">The <see cref="PostalCodes.PostalCodeFormat"/> to compare with the current <see cref="PostalCodes.PostalCodeFormat"/>.</param> /// <returns><c>true</c> if the specified <see cref="PostalCodes.PostalCodeFormat"/> is equal to the current /// <see cref="PostalCodes.PostalCodeFormat"/>; otherwise, <c>false</c>.</returns> public bool Equals(PostalCodeFormat other) { if (null == other) { return(false); } if ((RegexDefault == null && other.RegexDefault != null) || (RegexDefault != null && other.RegexDefault == null) || (RegexDefault != null && other.RegexDefault != null && !RegexDefault.ToString().Equals(other.RegexDefault.ToString()))) { return(false); } if ((RegexShort == null && other.RegexShort != null) || (RegexShort != null && other.RegexShort == null) || (RegexShort != null && other.RegexShort != null && !RegexShort.ToString().Equals(other.RegexShort.ToString()))) { return(false); } if (!String.Equals(Name, other.Name)) { return(false); } if (!String.Equals(OutputDefault, other.OutputDefault)) { return(false); } if (!String.Equals(OutputShort, other.OutputShort)) { return(false); } if (AutoConvertToShort != other.AutoConvertToShort) { return(false); } if (!String.Equals(ShortExpansionAsLowestInRange, other.ShortExpansionAsLowestInRange)) { return(false); } if (!String.Equals(ShortExpansionAsHighestInRange, other.ShortExpansionAsHighestInRange)) { return(false); } if (!String.Equals(LeftPaddingCharacter, other.LeftPaddingCharacter)) { return(false); } return(true); }
/// <summary> /// 得到正则 /// </summary> /// <param name="regexDefault"></param> /// <param name="options"></param> /// <returns></returns> public Regex GetRegex(RegexDefault regexDefault, RegexOptions options) { return(new Regex(GetRegexRule(regexDefault), options)); }
/// <summary> /// 得到正则 /// </summary> /// <param name="regexDefault"></param> /// <returns></returns> public Regex GetRegex(RegexDefault regexDefault) { return(GetRegex(regexDefault, RegexOptions.None)); }