// 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); } }
// 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.")); } }