Exemplo n.º 1
0
        // ReSharper disable once ExcessiveIndentation
        public static IAddress[] StringToAddresses(string str)
        {
            var remoteAddresses = new List <IAddress>();

            foreach (var remoteAddress in str.Split(','))
            {
                if (SpecialAddress.TryParse(remoteAddress, out var specialAddress))
                {
                    remoteAddresses.Add(specialAddress);
                }
                else if (SingleIP.TryParse(remoteAddress, out SingleIP ip))
                {
                    remoteAddresses.Add(ip);
                }
                else if (IPRange.TryParse(remoteAddress, out var range))
                {
                    remoteAddresses.Add(range);
                }
                else if (NetworkAddress.TryParse(remoteAddress, out var network))
                {
                    remoteAddresses.Add(network);
                }
            }

            return(remoteAddresses.ToArray());
        }
Exemplo n.º 2
0
        public static IAddress[] StringToAddresses(string str)
        {
            var remoteAddresses = new List <IAddress>();

            foreach (var remoteAddress in str.Split(','))
            {
                DNSService     dns;
                DHCPService    dhcp;
                WINSService    wins;
                LocalSubnet    localSubnet;
                DefaultGateway defaultGateway;
                IPRange        range;
                SingleIP       ip;
                NetworkAddress network;
                if (DNSService.TryParse(remoteAddress, out dns))
                {
                    remoteAddresses.Add(dns);
                }
                else if (DHCPService.TryParse(remoteAddress, out dhcp))
                {
                    remoteAddresses.Add(dhcp);
                }
                else if (WINSService.TryParse(remoteAddress, out wins))
                {
                    remoteAddresses.Add(wins);
                }
                else if (LocalSubnet.TryParse(remoteAddress, out localSubnet))
                {
                    remoteAddresses.Add(localSubnet);
                }
                else if (DefaultGateway.TryParse(remoteAddress, out defaultGateway))
                {
                    remoteAddresses.Add(defaultGateway);
                }
                else if (IPRange.TryParse(remoteAddress, out range))
                {
                    remoteAddresses.Add(range);
                }
                else if (SingleIP.TryParse(remoteAddress, out ip))
                {
                    remoteAddresses.Add(ip);
                }
                else if (NetworkAddress.TryParse(remoteAddress, out network))
                {
                    remoteAddresses.Add(network);
                }
            }
            return(remoteAddresses.ToArray());
        }
        // ReSharper disable once ExcessiveIndentation
        public static IAddress[] StringToAddresses(string str)
        {
            var remoteAddresses = new List <IAddress>();

            foreach (var remoteAddress in str.Split(','))
            {
                if (DNSService.TryParse(remoteAddress, out var dns))
                {
                    remoteAddresses.Add(dns);
                }
                else if (DHCPService.TryParse(remoteAddress, out var dhcp))
                {
                    remoteAddresses.Add(dhcp);
                }
                else if (WINSService.TryParse(remoteAddress, out var wins))
                {
                    remoteAddresses.Add(wins);
                }
                else if (LocalSubnet.TryParse(remoteAddress, out var localSubnet))
                {
                    remoteAddresses.Add(localSubnet);
                }
                else if (DefaultGateway.TryParse(remoteAddress, out var defaultGateway))
                {
                    remoteAddresses.Add(defaultGateway);
                }
                else if (IPRange.TryParse(remoteAddress, out var range))
                {
                    remoteAddresses.Add(range);
                }
                else if (SingleIP.TryParse(remoteAddress, out SingleIP ip))
                {
                    remoteAddresses.Add(ip);
                }
                else if (NetworkAddress.TryParse(remoteAddress, out var network))
                {
                    remoteAddresses.Add(network);
                }
            }

            return(remoteAddresses.ToArray());
        }
Exemplo n.º 4
0
 private System.Collections.Generic.List <IPRange> ParseIPRangeList(AddressFamily addressFamily, string list)
 {
     System.Collections.Generic.List <IPRange> list2 = new System.Collections.Generic.List <IPRange>();
     string[] array = list.Split(new char[]
     {
         ',',
         ' '
     });
     string[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         string  text  = array2[i];
         string  text2 = text.Trim();
         IPRange item;
         if (text2.Length > 0 && IPRange.TryParse(addressFamily, text2, out item))
         {
             list2.Add(item);
         }
     }
     return(list2);
 }