GetAttribute() public method

public GetAttribute ( string attributeName ) : ConfigurationAttribute
attributeName string
return ConfigurationAttribute
Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        public static void Uninstall(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();

                for (int i = 0; i < listenerAdaptersCollection.Count; i++)
                {
                    WebAdmin.ConfigurationElement element = listenerAdaptersCollection[i];

                    if (string.Compare((string)element.GetAttribute("name").Value,
                                       UdpConstants.Scheme, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        listenerAdaptersCollection.RemoveAt(i);
                    }
                }

                sm.CommitChanges();
                wasConfiguration = null;
                sm = null;
            }

            if (options.ProtocolHandlerChecked)
            {
                Configuration    rootWebConfig = GetRootWebConfiguration();
                ProtocolsSection section       = (ProtocolsSection)rootWebConfig.GetSection(ProtocolsPath);
                section.Protocols.Remove(UdpConstants.Scheme);
                rootWebConfig.Save();
            }
        }
 static internal object GetAttributeValue(ConfigurationElement element, string attributeName)
 {
     return element.GetAttribute(attributeName).Value;
 }