public static void Install(UdpInstallerOptions options)
{
if (options.ListenerAdapterChecked)
{
WebAdmin.ServerManager sm = new WebAdmin.ServerManager();
WebAdmin.Configuration wasConfiguration = sm.GetApplicationHostConfiguration();
WebAdmin.ConfigurationSection section = wasConfiguration.GetSection(ListenerAdapterPath);
WebAdmin.ConfigurationElementCollection listenerAdaptersCollection = section.GetCollection();
WebAdmin.ConfigurationElement element = listenerAdaptersCollection.CreateElement();
element.GetAttribute("name").Value = UdpConstants.Scheme;
element.GetAttribute("identity").Value = WindowsIdentity.GetCurrent().User.Value;
listenerAdaptersCollection.Add(element);
sm.CommitChanges();
wasConfiguration = null;
sm = null;
}
if (options.ProtocolHandlerChecked)
{
Configuration rootWebConfig = GetRootWebConfiguration();
ProtocolsSection section = (ProtocolsSection)rootWebConfig.GetSection(ProtocolsPath);
ProtocolElement element = new ProtocolElement(UdpConstants.Scheme);
element.ProcessHandlerType = typeof(UdpProcessProtocolHandler).AssemblyQualifiedName;
element.AppDomainHandlerType = typeof(UdpAppDomainProtocolHandler).AssemblyQualifiedName;
element.Validate = false;
section.Protocols.Add(element);
rootWebConfig.Save();
}
}