예제 #1
0
        public void Edit(string profileName)
        {
            var profiles         = _store.Retrieve().ToList();
            var possibleProfiles = profiles.Where(p => p.Name.Equals(profileName, StringComparison.OrdinalIgnoreCase));

            if (possibleProfiles.Count() != 1)
            {
                return;
            }

            _editingProfile = possibleProfiles.First();
            Profile newProfile;

            if (DHCP)
            {
                newProfile = Profile.CreateDHCPProfile(Name);
            }
            if (DNS != IPAddress.Any)
            {
                newProfile = Profile.CreateStaticProfile(Name, IP, Subnet, Gateway, new IPAddress[] { DNS });
            }
            if (Gateway != IPAddress.Any)
            {
                newProfile = Profile.CreateStaticProfile(Name, IP, Subnet, Gateway);
            }
            else
            {
                newProfile = Profile.CreateStaticProfile(Name, IP, Subnet);
            }

            profiles.Remove(_editingProfile);
            profiles.Add(newProfile);
            _store.Store(profiles);
        }