Implementing a configuration class

The configuration file is used by the manager class. The configuration class must provide infomration about the available data providers and the definitions of the frontend and the backend views.

To create a configuration class, perform the following:

  1. From the context menu of the folder Configuration in the LocationsModule project, click Add » Class.
  2. Name the class file LocationsConfig.cs and click Add.
  3. Open the file LocationsConfig.cs.
  4. Add the following using statments:

    • using Telerik.Sitefinity.Modules.GenericContent.Configuration;
    • using Telerik.Sitefinity.Configuration;
    • using LocationsModule.Data.Implementation;
    • using System.Collections.Specialized;
    • using Telerik.Sitefinity.Web.UI.ContentUI.Config;
    • using System.Configuration;
  5. Make the LocationsConfig class inherit the ContentModuleConfigBase class:

    public class LocationsConfig : ContentModuleConfigBase
    {
    }
  6. Implement the following abstract members of the ContentModuleConfigBase class:

    • InitializeDefaultProviders - initializes the providers available for the module.
    • InitializeDefaultViews - initializes the frontend and backend views.

    Following is the code for these members:

    protected override void InitializeDefaultProviders(ConfigElementDictionary<string, DataProviderSettings> providers)
    {
        providers.Add(new DataProviderSettings(providers)
        {
            Name = "OpenAccessLocationsDataProvider",
            Description = "A provider that stores locations data in database using OpenAccess ORM.",
            ProviderType = typeof(OpenAccessLocationsDataProvider),
            Parameters = new NameValueCollection() { { "applicationName", "/Locations" } }
        });
    }
     
    protected override void InitializeDefaultViews(ConfigElementDictionary<string, ContentViewControlElement> contentViewControls)
    {
        // add backend views to configuration
        contentViewControls.Add(LocationsDefinitions.DefineLocationsBackendContentView(contentViewControls));
     
        // add frontend views to configuration
        contentViewControls.Add(LocationsDefinitions.DefineLocationsFrontendContentView(contentViewControls));
    }

    NOTE: The frontend and backend views are defined via definitions. You will implement them later in this tutorial. For more information, see Creating the definitions class.

  7. Override the DefaultProvider property in the following way:

    [ConfigurationProperty("defaultProvider", DefaultValue = "OpenAccessLocationsDataProvider")]
    public override string DefaultProvider
    {
        get { return (string)this["defaultProvider"]; }
        set { this["defaultProvider"] = value; }
    }

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK