private string GetLocalizedString(string[] elements) { StringBuilder stringBuilder = new StringBuilder(); foreach (string text in elements) { if (text.Length > 1 && text[0] == '<' && text[text.Length - 1] == '>') { string value = text.Substring(1, text.Length - 2); if (Enum.IsDefined(typeof(GroupNamingPolicyAttributeEnum), value)) { GroupNamingPolicyAttributeEnum groupNamingPolicyAttributeEnum = (GroupNamingPolicyAttributeEnum)Enum.Parse(typeof(GroupNamingPolicyAttributeEnum), value); stringBuilder.AppendFormat("<{0}>", LocalizedDescriptionAttribute.FromEnum(typeof(GroupNamingPolicyAttributeEnum), groupNamingPolicyAttributeEnum)); } else { stringBuilder.Append(DistributionGroupNamingPolicy.UnescapeText(text)); } } else { stringBuilder.Append(DistributionGroupNamingPolicy.UnescapeText(text)); } } return(stringBuilder.ToString()); }
public static DistributionGroupNamingPolicy Parse(string namingPolicy) { DistributionGroupNamingPolicy result = null; if (!DistributionGroupNamingPolicy.TryParse(namingPolicy, out result)) { throw new FormatException(DirectoryStrings.InvalidDistributionGroupNamingPolicyFormat(namingPolicy, DistributionGroupNamingPolicy.placeHoldersString)); } return(result); }
public static bool TryParse(string namingPolicy, out DistributionGroupNamingPolicy instance) { if (string.IsNullOrEmpty(namingPolicy)) { instance = new DistributionGroupNamingPolicy(namingPolicy); return(true); } if (char.IsWhiteSpace(namingPolicy[0]) || char.IsWhiteSpace(namingPolicy[namingPolicy.Length - 1])) { instance = null; return(false); } Match match = DistributionGroupNamingPolicy.namingPolicyValidationRegex.Match(namingPolicy); if (!match.Success || match.Groups["originalName"].Captures.Count != 1) { instance = null; return(false); } instance = new DistributionGroupNamingPolicy(namingPolicy); return(true); }