public int Decimal2CIDR(IPAddress decimalMask)
        {
            if (decimalMask != null)
            {
                return(0);
            }

            return(CIDRDecimalConvertor.Decimal2CIDR(decimalMask.ToString()));
        }
        private void Initialize()
        {
            //make sure the ip helper is bootstraped
            if (!isBootstraped)
            {
                throw new ArgumentException("IP Pool Helper is not Initialize.");
            }

            //iterate the pool list
            foreach (KeyValuePair <string, string> item in _poolList)
            {
                //get the extension
                string extension = Path.GetExtension(item.Value);
                //file reader instance
                IFileReader fileReader = FileReaderFactory.CreateReader(extension);
                //load the ip pool
                IList <string> ipPools = fileReader.Read(item.Value);
                foreach (var op in ipPools)
                {
                    string   formatedIP = IPAddressParser.Parse(op);
                    string[] poolArr    = formatedIP.Trim().Split('/');
                    if (poolArr.Length > 0)
                    {
                        int subnetMast;
                        Int32.TryParse(poolArr[1], out subnetMast);
                        string    poolIp = poolArr[0].Replace(" ", "");
                        IPAddress ipAddr = IPAddress.Parse(poolIp);
                        IPAddress mask   = IPAddress.Parse(CIDRDecimalConvertor.CIDR2Decimal(subnetMast));
                        AddSubnetMaskToDictonary(item.Key, mask);

                        IPAddress netAddOfIP = ipAddr.GetNetworkAddress(mask);
                        AddNetAddressToDictonary(item.Key, netAddOfIP, op);
                    }
                }
            }
            //set the initialize flag to true
            isInitialized = true;
        }
 public int Decimal2CIDR(string decimalMask)
 {
     return(CIDRDecimalConvertor.Decimal2CIDR(decimalMask));
 }
 public string CIDR2Decimal(int cidr)
 {
     return(CIDRDecimalConvertor.CIDR2Decimal(cidr));
 }