/// <summary> Populates this IP_Restriction range information with all of the IP Restriction ranges for this library </summary> /// <param name="All_Ranges"> DataTable containing all of the IP ranges </param> public void Populate_IP_Ranges(DataTable All_Ranges) { lock (thisLock) { DataColumn startColumn = All_Ranges.Columns["StartIP"]; DataColumn endColumn = All_Ranges.Columns["EndIP"]; rangeDictionary.Clear(); IpRanges.Clear(); IP_Restriction_Range currentRange = null; foreach (DataRow thisRow in All_Ranges.Rows) { // Check if this is the same range, or add a new one int ipRangeId = Convert.ToInt32(thisRow[1]); if ((currentRange == null) || (currentRange.RangeID != ipRangeId)) { currentRange = new IP_Restriction_Range(ipRangeId, thisRow[0].ToString(), thisRow[2].ToString(), thisRow[5].ToString()); IpRanges.Add(currentRange); rangeDictionary[currentRange.RangeID] = currentRange; } // Add all the IP addresses to this string start = thisRow[startColumn].ToString().Trim(); if (start.Length > 0) { currentRange.Add_IP_Address(start, thisRow[endColumn].ToString().Trim()); } } } }
private void AddIpRange() { const byte maxIpRanges = byte.MaxValue; if (IpRanges.Count < maxIpRanges) { IpRanges.Add(new IpRangeViewModel()); } }