Exemple #1
0
 // Wendet einstellungen aus dem Profil an
 public void ApplyProfile(IpProfile profile)
 {
     if (profile.IsValid())
     {
         NetworkInterface currentInterface = GetInterface(profile.GetInterfaceName());
         if (profile.GetDynamicIp())
         {
             NetworkSettingsControler.SetIpToDynamic(currentInterface);
             if (profile.GetDynamicDns())
             {
                 NetworkSettingsControler.SetNameserversToDynamic(currentInterface);
             }
             else
             {
                 NetworkSettingsControler.SetStaticNameservers(currentInterface, profile.GetNameservers());
             }
         }
         else
         {
             NetworkSettingsControler.SetStaticIp(currentInterface, profile.GetIpAddress(), profile.GetSubnetMask());
             NetworkSettingsControler.SetStaticGateway(currentInterface, profile.GetDefaultGateway());
             NetworkSettingsControler.SetStaticNameservers(currentInterface, profile.GetNameservers());
         }
     }
     else
     {
         throw new Exception(string.Concat("IPProfil ", profile.GetProfileName(), " ist ungültig."));
     }
 }
        // update a profile
        public void UpdateProfile(IpProfile newProfile)
        {
            bool addProfile = true;

            foreach (IpProfile profile in profiles)
            {
                if (profile.GetGuid() == newProfile.GetGuid())
                {
                    addProfile = false;
                    profile.SetProfileName(newProfile.GetProfileName());
                    profile.SetInterfaceName(newProfile.GetInterfaceName());
                    profile.SetDynamicIp(newProfile.GetDynamicIp());
                    profile.SetIpAddress(newProfile.GetIpAddress());
                    profile.SetSubnetMask(newProfile.GetSubnetMask());
                    profile.SetDefaultGateway(newProfile.GetDefaultGateway());
                    profile.SetDynamicDns(newProfile.GetDynamicDns());
                    profile.SetNameservers(newProfile.GetNameservers());
                    break;
                }
            }
            if (addProfile)
            {
                AddProfile(newProfile);
            }
        }
 // remove a profile
 public void RemoveProfile(IpProfile profile)
 {
     for (int i = 0; i < profiles.Count; i++)
     {
         if (profiles[i].GetGuid() == profile.GetGuid())
         {
             profiles.RemoveAt(i);
             break;
         }
     }
 }
 // add a profile
 public void AddProfile(IpProfile profile)
 {
     profiles.Add(profile);
 }
Exemple #5
0
 public void ApplyProfile(IpProfile profile)
 {
     interfaceManager.ApplyProfile(profile);
 }
Exemple #6
0
 public void DeleteProfile(IpProfile oldProfile)
 {
     profileManager.RemoveProfile(oldProfile);
     configManager.SaveProfiles(profileManager.GetProfiles());
 }
Exemple #7
0
 public void UpdateProfile(IpProfile newProfile)
 {
     profileManager.UpdateProfile(newProfile);
     configManager.SaveProfiles(profileManager.GetProfiles());
 }