Esempio n. 1
0
        public AdapterList(uint aSubnet)
        {
            using(SubnetList subnets = new SubnetList())
            {
                bool found = false;

                uint count = subnets.Size();

                iSubnets = new List<uint>();
                iAdapters = new List<string>();

                for(uint i = 0; i < count; ++i)
                {
                    NetworkAdapter adapter = subnets.SubnetAt(i);

                    iSubnets.Add(adapter.Subnet());
                    iAdapters.Add(adapter.Name());

                    if(!found)
                    {
                        if(adapter.Subnet() == aSubnet)
                        {
                            found = true;
                            iCurrent = i;
                            iAdapter = adapter;
                            iAdapter.AddRef("Konfig-Adapter-List");
                        }
                    }
                }

                if(!found)
                {
                    if(aSubnet == 0 || !found)
                    {
                        // uninitialised or not found

                        if(count > 0)
                        {
                            iCurrent = 0;
                            iAdapter = subnets.SubnetAt(0);
                            iAdapter.AddRef("Konfig-Adapter-List");
                        }
                    }

                    if (aSubnet != 0)
                    {
                        iSubnets.Add(aSubnet);
                        iAdapters.Add("Network not present");
                    }
                }
            }
        }