Implementing the configuration class

The configuration file is used by the manager class. The configuration class must provide information 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 ProductsModule project, click Add » Class.
  2. Name the class file ProductsConfig.cs and click Add.
  3. Open the file ProductsConfig.cs.
  4. Add the following using statements:

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

    public class ProductsConfig : 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 = "OpenAccessDataProvider",
            Description = "A provider that stores news data in database using OpenAccess ORM.",
            ProviderType = typeof(OpenAccessDataProvider),
            Parameters = new NameValueCollection() { { "applicationName", "/Products" } }
        });
    }
     
    protected override void InitializeDefaultViews(ConfigElementDictionary<string, ContentViewControlElement> contentViewControls)
    {
        contentViewControls.Add(ProductsDefinitions.DefineProductsBackendContentView(contentViewControls));
     
        contentViewControls.Add(
                CommentsDefinitions.DefineCommentsBackendContentView(
                contentViewControls,
                ProductsDefinitions.BackendCommentsDefinitionName,
                this.DefaultProvider,
                typeof(ProductsManager),
                typeof(ProductsResources).Name));
     
        contentViewControls.Add(ProductsDefinitions.DefineProductsFrontendContentView(contentViewControls));
     
        contentViewControls.Add(
                CommentsDefinitions.DefineCommentsFrontendView(
                contentViewControls,
                ProductsDefinitions.FrontendCommentsDefinitionName,
                this.DefaultProvider,
                typeof(ProductsManager)));
    }

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

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