Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ProviderFeature Class

ProviderFeature Class

Provides the base class for module providers.

System..::..Object
  Microsoft.Web.Management.Client.Extensions..::..ProviderFeature

Namespace:  Microsoft.Web.Management.Client.Extensions
Assembly:  Microsoft.Web.Management (in Microsoft.Web.Management.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public abstract class ProviderFeature

The ProviderFeature type exposes the following members.

  NameDescription
Protected methodProviderFeatureInitializes a new instance of the ProviderFeature class.
Top

  NameDescription
Public propertyConnectionStringAttributeNameGets the name of the connection string to the provider database.
Public propertyConnectionStringRequiredGets a value indicating whether a connection string is required to access the database.
Public propertyFeatureNameWhen overridden in a derived class, gets the name of the feature for the provider.
Public propertyProviderBaseTypeWhen overridden in a derived class, gets the type of provider.
Public propertyProviderCollectionPropertyNameWhen overridden in a derived class, gets the name of the provider collection.
Public propertyProviderConfigurationSettingNamesWhen overridden in a derived class, gets a collection with the setting names for the provider.
Public propertySectionNameWhen overridden in a derived class, gets the configuration section that set up the provider.
Public propertySelectedProviderWhen overridden in a derived class, gets the name of the selected provider.
Public propertySelectedProviderPropertyNameWhen overridden in a derived class, gets the name of the attribute that specifies the currently selected provider.
Public propertySettingsWhen overridden in a derived class, gets the configuration settings for the provider.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

Modules that must configure providers have a feature that derives from this class. You can use this class to implement your own custom provider.

Once configured, the derived class will appear in the Feature drop-down box on the Providers page. The FeatureName property value will appear along with the predefined providers .NET Roles, .NET Users, and .NET Profile.

You can use the user interface (UI) in IIS Manager to add, edit, rename, or remove providers. Modifying a provider will result in a change to the Web.config file (located in the .NET Framework version 2.0 folder).

When you use this extensibility feature, you must also write a Module object and a ModuleProvider object to register the ProviderFeature class with the extensibility manager. The example below displays the coding for these three classes along with a ProviderConfigurationSettings class needed to establish the configuration setting for the provider.

Notes to Inheritors

When you inherit from the ProviderFeature class, you must override the following members:

The following example adds a provider (.NET Site Map) derived from a SiteMapProvider object. You will need the following four classes as part of your project.

SiteMapProviderConfigurationFeature

using System;
using Microsoft.Web.Management.Client.Extensions;
using Microsoft.Web.Management.Client;

namespace ProviderConfigurer {

    public class SiteMapProviderConfigurationFeature : ProviderFeature
    {
        public SiteMapProviderConfigurationFeature()
        {
            _selectedProvider = FeatureName;
        }

        public SiteMapProviderConfigurationFeature(string selectedProvider)
        {
            _selectedProvider = selectedProvider;
        }

        private string _selectedProvider;
        // The name that will show up in drop down on "Providers" page.
        public override string  FeatureName
        {
            get { return ".NET Site Map"; }
        }
        // The site map provider base type. The provider that is
        // configured will derive from this base type.
        public override string  ProviderBaseType
        {
	        get { return "System.Web.SiteMapProvider"; }
        }
        // The siteMap providers collection is a collection inside a <providers> tag.
        public override string  ProviderCollectionPropertyName
        {
	        get { return "providers"; }
        }

        // Each provider can be configured with these attributes.
        public override string[]  ProviderConfigurationSettingNames
        {
            get {
                return new string[] {"siteMapFile", 
                                     "description",
                                     "connectionStringName"};
            }
        }
        // The section for the siteMap element.
        public override string  SectionName
        {
            get { return "system.web/siteMap"; }
        }
        // The currently selected provider. 
        public override string SelectedProvider 
        {
            get {
                if (_selectedProvider == null)
                {
                    return String.Empty;
                }
                return _selectedProvider; }
        }
        // The name of the attribute that specifies the currently selected provider.
        public override string  SelectedProviderPropertyName
        {
            get {
                return "defaultProvider"; }
        }
        // Initializes the settings for the provider.
        public override ProviderConfigurationSettings Settings
        {
	        get {return new SiteMapProviderConfigurationSettings();}
        }
    }
}


SiteMapProviderConfigurationFeatureModule

using System;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.Server;
using System.Diagnostics;
using Microsoft.Web.Management.Client.Extensions;

namespace ProviderConfigurer {
    class SiteMapProviderConfigurationFeatureModule : Module{
        protected override void Initialize(
            IServiceProvider serviceProvider, ModuleInfo moduleInfo)
        {
            base.Initialize(serviceProvider, moduleInfo);

            Connection connection = (Connection)serviceProvider.GetService(
                typeof(Connection));
            Debug.Assert(connection != null);

            // Register the extensibility features with the extensibility manager
            IExtensibilityManager extensibilityManager = 
                (IExtensibilityManager)serviceProvider.GetService(
                typeof(IExtensibilityManager));
            Debug.Assert(extensibilityManager != null);

            if (extensibilityManager != null) {
                // Provider configuration
                SiteMapProviderConfigurationFeature siteMapProviderConfigurationFeature
                    = new SiteMapProviderConfigurationFeature();
                extensibilityManager.RegisterExtension(typeof(ProviderFeature),
                    siteMapProviderConfigurationFeature);
            }
        }

        protected override bool IsPageEnabled(ModulePageInfo pageInfo)
        {
            return true;
        }
    }
}


SiteMapProviderConfigurationFeatureModuleProvider

using System;
using Microsoft.Web.Management.Server;

namespace ProviderConfigurer {
    class SiteMapProviderConfigurationFeatureModuleProvider : ModuleProvider {
        public override Type ServiceType {
            get { return null; }
        }

        public override ModuleDefinition GetModuleDefinition(IManagementContext context) {
            return new ModuleDefinition(Name, typeof(
                SiteMapProviderConfigurationFeatureModule).AssemblyQualifiedName);

        }

        public override bool SupportsScope(ManagementScope scope) {
            return true;
        }
    }
}


SiteMapProviderConfigurationSettings

using System;
using System.Collections;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.AspNet;

namespace ProviderConfigurer
{
    public class SiteMapProviderConfigurationSettings : ProviderConfigurationSettings
    {
        Hashtable _settings;

        public SiteMapProviderConfigurationSettings()
        {
            _settings = new Hashtable();
        }

        public string SiteMapFile
        {
            get
            {
                if (_settings["siteMapFile"] != null)
                {
                    return (string)_settings["siteMapFile"];
                }
                return String.Empty;
            }
            set
            {
                _settings["siteMapFile"] = value;
            }
        }

        // overrides the abstract Settings property.
        protected override System.Collections.IDictionary Settings
        {
            get
            {
                return (IDictionary)_settings;
            }
        }

        // Overrides the abstract Validate method.
        public override bool Validate(out string message)
        {
            // Perform a validation check. If the key pairs collection
            // contains more than three pairs, pass a return value of 
            // false and a failure message.
            if (_settings.Count < 4)
            {
                message = "Validation succesful";
                return true;
            }
            else
            {
                message = "Validation failed - too many key value pairs";
                return false;
            }
        }
    }
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2015 Microsoft