using System;

using CMS.GlobalHelper;
using CMS.SettingsProvider;
using CMS.SiteProvider;
using CMS.WorkflowEngine;

/// <summary>
/// Sample class loader module class. Partial class ensures correct registration.
/// </summary>
[MyMediaSearchLoader]
public partial class CMSModuleLoader
{
    /// <summary>
    /// Module registration
    /// </summary>
    private class MyMediaSearchLoaderAttribute : CMSLoaderAttribute
    {
        /// <summary>
        /// Initializes the module
        /// </summary>
        public override void Init()
        {
            // -- This line provides the ability to register the classes via web.config cms.extensibility section from App_Code
            ClassHelper.OnGetCustomClass += ClassHelper_OnGetCustomClass;
        }


        /// <summary>
        /// Gets the custom class object based on the given parameters
        /// </summary>
        private void ClassHelper_OnGetCustomClass(object sender, ClassEventArgs e)
        {
            if (e.Object == null)
            {
                // Provide your custom classes
                switch (e.ClassName)
                {
                    // Class MyMediaSearchIndex implementing ICustomSearchIndex
                    case "MyMediaSearchIndex":
                        e.Object = new MyMediaSearchIndex();
                        break;

                    // Class MyMediaSearchAnalyzer implementing Analyzer
                    case "MyMediaSearchAnalyzer":
                        e.Object = new MyMediaSearchAnalyzer();
                        break;

                    // Class MyMediaSearchAnalyzer implementing ITask
                    case "MyMediaSearchTaskExecutor":
                        e.Object = new MyMediaSearchTaskExecutor();
                        break;
                }
            }
        }
    }
}
