Esempio n. 1
0
        public IEnumerable<AddressRange> Parse(Stream stream)
        {
            var reader = new StreamReader(stream);

            string result = null;
            var r = new Regex(@"([0-9]{1,3}\.){3,3}[0-9]{1,3}");

            while ((result = reader.ReadLine()) != null)
            {
                MatchCollection collection = r.Matches(result);
                if (collection.Count == 1)
                {
                    var range = new AddressRange();
                    string[] s = collection[0].Captures[0].Value.Split('.');
                    range.Start = (int.Parse(s[0]) << 24) | (int.Parse(s[1]) << 16) | (int.Parse(s[2]) << 8) | (int.Parse(s[3]));
                    range.End = range.Start;
                    yield return range;
                }
                else if (collection.Count == 2)
                {
                    string[] s = collection[0].Captures[0].Value.Split('.');
                    int start = (int.Parse(s[0]) << 24) | (int.Parse(s[1]) << 16) | (int.Parse(s[2]) << 8) | (int.Parse(s[3]));

                    s = collection[1].Captures[0].Value.Split('.');
                    int end = (int.Parse(s[0]) << 24) | (int.Parse(s[1]) << 16) | (int.Parse(s[2]) << 8) | (int.Parse(s[3]));

                    var range = new AddressRange();
                    range.Start = start;
                    range.End = end;
                    yield return range;
                }
            }
        }
Esempio n. 2
0
 public void Add(AddressRange addressRange)
 {
     addresses.Add(addressRange);
 }
Esempio n. 3
0
 public bool Contains(AddressRange range)
 {
     return range.Start >= Start && range.End <= End;
 }
Esempio n. 4
0
 private void Remove(AddressRange addressRange)
 {
     addresses.Remove(addressRange);
 }
Esempio n. 5
0
 void Remove(AddressRange addressRange)
 {
     addresses.Remove(addressRange);
 }
Esempio n. 6
0
 public void Add(AddressRange addressRange)
 {
     addresses.Add(addressRange);
 }
Esempio n. 7
0
 public bool Contains(AddressRange range)
 {
     return(range.Start >= Start && range.End <= End);
 }