public static bool TryParse(string expression, out DatabaseAvailabilityGroupSubnetId subnetId) { subnetId = null; IPRange ipRange = null; if (IPRange.TryParse(expression, out ipRange)) { subnetId = new DatabaseAvailabilityGroupSubnetId(ipRange); return(true); } return(false); }
private static bool TryParse(string stringToParse, out ServiceProviderSettings settings, out string error) { settings = null; error = null; if (string.IsNullOrWhiteSpace(stringToParse)) { error = "String passed is null or empty"; return(false); } string[] array = stringToParse.Split(new char[] { ',' }); if (array.Length != 4) { error = "We need a CSV with 4 values - Provider name, Provider url, IP ranges and Certificate names"; return(false); } char[] separator = new char[] { ';' }; List <IPRange> list = null; List <TlsCertificate> list2 = null; bool flag = true; if (!string.IsNullOrWhiteSpace(array[2])) { list = new List <IPRange>(); string[] array2 = array[2].Split(separator); foreach (string text in array2) { if (!string.IsNullOrWhiteSpace(text)) { IPRange item; if (IPRange.TryParse(text.Trim(), out item)) { list.Add(item); } else { error = string.Format("{0}Invalid IP Range {1}.", error, text); flag = false; } } } } if (!string.IsNullOrWhiteSpace(array[3])) { list2 = new List <TlsCertificate>(); string[] array4 = array[3].Split(separator); foreach (string text2 in array4) { if (!string.IsNullOrWhiteSpace(text2)) { TlsCertificate item2; if (TlsCertificate.TryParse(text2.Trim(), out item2)) { list2.Add(item2); } else { error = string.Format("{0}Invalid Tls certificate {1}.", error, text2); flag = false; } } } } if (flag) { settings = new ServiceProviderSettings(array[0].Trim(), array[1].Trim(), list, list2, stringToParse); } return(flag); }