using System.Configuration; namespace S22.Sasl { /// /// Represents the sasl section within a configuration /// file. /// public class SaslConfigurationSection : ConfigurationSection { /// /// The saslProviders section contains a collection of /// saslProvider elements. /// [ConfigurationProperty("saslProviders", IsRequired = false, IsKey = false, IsDefaultCollection = false)] public SaslProviderCollection SaslProviders { get { return ((SaslProviderCollection) base["saslProviders"]); } set { base["saslProviders"] = value; } } } /// /// Represents a saslProvider configuration element within the /// saslProviders section of a configuration file. /// [ConfigurationCollection(typeof(SaslProvider), CollectionType=ConfigurationElementCollectionType.BasicMapAlternate)] public class SaslProviderCollection : ConfigurationElementCollection { /// /// The name of the configuration element. /// internal const string PropertyName = "saslProvider"; /// /// Gets the name used to identify this collection of elements /// in the configuration file. /// protected override string ElementName { get { return PropertyName; } } /// /// Returns the SaslProvider instance for the saslProvider /// element with the specified name. /// /// The name of the saslProvider element to /// retrieve. /// The SaslProvider instance with the specified name /// or null. public new SaslProvider this[string name] { get { return (SaslProvider) BaseGet(name); } } /// /// Returns the SaslProvider instance for the saslProvider /// element at the specified index. /// /// The index of the saslProvider element /// to retrieve. /// The SaslProvider instance with the specified /// index. /// Thrown if the /// index is less than 0 or if there is no SaslProvider instance /// at the specified index. public SaslProvider this[int index] { get { return (SaslProvider) BaseGet(index); } } /// /// Gets the collection type of the SaslProviderCollection. /// public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMapAlternate; } } /// /// Indicates whether the specified System.Configuration.ConfigurationElement /// exists in the SaslProviderCollection. /// /// The name of the element to verify. /// Returns true if the element exists in the collection, /// otherwise false. protected override bool IsElementName(string elementName) { return elementName == PropertyName; } /// /// Creates a new instance of the SaslProvider class. /// /// A new instance of the SaslProvider class. protected override ConfigurationElement CreateNewElement() { return new SaslProvider(); } /// /// Gets the element key for the specified SaslProvider element. /// /// A SaslProvider element to retrieve the /// element key for. /// The unique element key of the specified SaslProvider /// instance. protected override object GetElementKey(ConfigurationElement element) { return ((SaslProvider) element).Name; } } /// /// Represents a saslProvider section within the saslProviders /// section of a configuration file. /// public class SaslProvider : ConfigurationSection { /// /// The name of the saslProvider. This attribute must be unique in /// that no two saslProvider elements exists that have the same /// name attribute. /// [ConfigurationProperty("name", IsRequired = true)] public string Name { get { return (string) base["name"]; } set { base["name"] = value; } } /// /// The type name of the SaslMechanism exposed by the /// saslProvider. /// [ConfigurationProperty("type", IsRequired = true)] public string Type { get { return (string) base["type"]; } set { base["type"] = value; } } /// /// Retrieves the setting with the specified name for this saslProvider. /// /// The name of the setting to retrieve. /// The value of the setting with the specified name or null /// if the setting could not be found. public new string this[string name] { get { if (Settings[name] != null) return Settings[name].Value; return null; } } /// /// Represents a collection of arbitrary name-value pairs which can be /// added to the saslProvider element. /// [ConfigurationProperty("", IsDefaultCollection = true)] public NameValueConfigurationCollection Settings { get { return (NameValueConfigurationCollection) base[""]; } } } }