public void Load()
        {
            using (StreamReader reader = new StreamReader(path))
            {
                string s = reader.ReadLine();
                mac.Change(s);
                while ((s = reader.ReadLine()) != null)
                {
                    NetInterface netInterface = null;
                    switch (s)
                    {
                    case "eth":
                        netInterface = new Ethernet(interfaces.Count, mac.Value);
                        break;

                    case "wifi":
                        netInterface = new Wifi(interfaces.Count, mac.Value);
                        break;

                    case "con":
                        netInterface = new Console(interfaces.Count, mac.Value);
                        break;
                    }
                    int count = Convert.ToInt32(reader.ReadLine());
                    for (int i = 0; i < count; i++)
                    {
                        s = reader.ReadLine();
                        string[] split = s.Split(' ');
                        netInterface.ChangeSetting(split[0], split[1]);
                    }
                    interfaces.Add(netInterface);
                }
            }
        }
        public bool SaveInterface(NetInterface netInterface)
        {
            List <NetInterface> interfaces = parameterService.GetListInterface();
            int i = 0;

            while (i < interfaces.Count &&
                   !interfaces[i].name.Equals(netInterface.name))
            {
                i++;
            }
            if (i == interfaces.Count)
            {
                return(false);
            }
            parameterService.SaveInterface(i, netInterface);
            return(true);
        }
Ejemplo n.º 3
0
 public FormInterface(NetInterface netInterface)
 {
     InitializeComponent();
     this.netInterface = netInterface;
 }
 public void SaveInterface(int i, NetInterface netInterface)
 {
     interfaces[i] = netInterface;
 }