/// <summary> /// Converts a specified string to <see cref="ClientName"/>. /// </summary> /// <param name="value">The string to parse.</param> public static ClientName Parse(string value) { if (String.IsNullOrEmpty(value)) { return(new ClientName(null, null)); } // value is md5 hash if (Regex.IsMatch(value, "[0-9a-f]{32}")) { return(new ClientName(null, null) { Hash = value }); } // escaping slash value = ClientName.Encode(value); // value contains slash int slash = value.IndexOf("/"); if (slash == -1) { // does not contain a slash, is provider name return(new ClientName(null, ClientName.Decode(value))); } // contain a slash, is client name and provider name return(new ClientName ( ClientName.Decode(value.Substring(0, slash)), ClientName.Decode(value.Substring(slash + 1, value.Length - slash - 1)) )); }