Ejemplo n.º 1
0
        protected BaseTemplate(int moduleId, int tabModuleId, string templateName)
        {
            ModuleId = moduleId;
            TabModuleId = tabModuleId;
            _settings = new SettingsController().GetModuleSettings(ModuleId, TabModuleId);
            Name = templateName;

        }
        /// <summary>
        /// Callback method that dynamically loads a type of template, using reflection
        /// </summary>
        /// <param name="cacheItemArgs">Arguments, containing moduleid and tabModuleId </param>
        /// <returns>ITemplate</returns>
        private object GetTemplateCallback(CacheItemArgs cacheItemArgs)
        {
            var moduleId = (int)cacheItemArgs.ParamList[0];
            var tabModuleId = (int)cacheItemArgs.ParamList[1];
            var moduleSettings = new SettingsController().GetModuleSettings(moduleId, tabModuleId);


                Type type = Type.GetType("DotNetNuke.Modules.Announcements.Components.Template." + moduleSettings.TemplateType);
                if (type != null && type.IsClass)
                {
                    var template = Activator.CreateInstance(type,
                        new object[] { moduleId, tabModuleId, moduleSettings.TemplateName });
                    return template;
                }
            return null;

        }