public static IPAddressRange Parse(string str)
 {
     string[] array = str.Split(new char[]
     {
         '.'
     });
     IPAddressToken[] array2 = new IPAddressToken[4];
     if (array.Length != 4)
     {
         throw new FormatException(string.Format("{0} must contains 3 dots", str));
     }
     for (int i = 0; i < array.Length; i++)
     {
         array2[i] = IPAddressToken.Parse(array[i]);
     }
     return(new IPAddressRange(array2));
 }
Esempio n. 2
0
        public static IPAddressRange Parse(string str)
        {
            var split  = str.Split('.');
            var tokens = new IPAddressToken[4];

            if (split.Length != 4)
            {
                throw new FormatException(string.Format("{0} must contains 3 dots", str));
            }

            for (var i = 0; i < split.Length; i++)
            {
                tokens[i] = IPAddressToken.Parse(split[i]);
            }

            return(new IPAddressRange(tokens));
        }
        public static IPAddressToken Parse(string str)
        {
            str = str.Trim();
            IPAddressToken result;

            if (str == "*")
            {
                result = new IPAddressToken(true);
            }
            else
            {
                if (str.Contains("-"))
                {
                    byte low  = byte.Parse(str.Substring(0, str.IndexOf("-")).Trim());
                    byte high = byte.Parse(str.Remove(0, str.IndexOf("-") + 1).Trim());
                    result = new IPAddressToken(low, high);
                }
                else
                {
                    result = new IPAddressToken(byte.Parse(str));
                }
            }
            return(result);
        }