public static List <IpCatalogItem> LoadCatalog(string path) { var rawCatalog = new XmlDocument(); Logger.Log("Loading catalog from " + path); try { rawCatalog.Load(path); } catch (Exception ex) { throw new InvalidOperationException("Could not load catalog " + path, ex); } var ipElements = rawCatalog.GetElementsByTagName("ip"); var ipList = new List <IpCatalogItem>(); foreach (XmlNode ip in ipElements) { var item = new IpCatalogItem(ip); ipList.Add(item); // Utilities.Echo("Loaded: " + item.ToString()); } ipList.Sort(); Utilities.Echo("Loaded " + ipList.Count + " IP addresses"); CachedCatalog = ipList; return(ipList); }
public int CompareTo(IpCatalogItem ipItem) { if (ipItem == null) { return(1); } if (ipItem.IP == null) { return(1); } var thisIp = IP.ToString(); var thatIp = ipItem.IP.ToString(); var result = thisIp.CompareTo(thatIp); return(result); }