public void RegisterController_DummyController_IsRegisteredInStore()
        {
            var initializer = new DummyInitializer();
            var controller  = typeof(DummyController);

            using (new ObjectFactoryContainerRegion())
            {
                ObjectFactory.Container.RegisterType <ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(),
                                                                                    new InjectionConstructor(typeof(XmlConfigProvider).Name));
                ObjectFactory.Container.RegisterType <XmlConfigProvider, DummyConfigProvider>();
                Config.RegisterSection <ResourcesConfig>();
                Config.RegisterSection <ProjectConfig>();

                initializer.RegisterControllerPublic(controller);

                var resourceRegistered = ObjectFactory.Container.IsRegistered(typeof(DummyControllerResoruces), Res.GetResourceClassId(typeof(DummyControllerResoruces)));
                Assert.IsTrue(resourceRegistered, "String resources were not registered for the controller.");
            }

            var registration = ControllerStore.Controllers().SingleOrDefault(c => c.ControllerType == controller);

            Assert.IsNotNull(registration, "Controller was not registered.");

            var route = RouteTable.Routes[controller.Name];

            Assert.IsNull(route, "Route was registered for the controller.");
        }
Beispiel #2
0
        /// <summary>
        /// Register controllers into the store
        /// </summary>
        /// <param name="controllers">The controllers to be registered.</param>
        protected virtual void RegisterControllers(IEnumerable <Type> controllers)
        {
            var controllerStore = new ControllerStore();

            controllerStore.AddControllers(controllers.ToArray(), ConfigManager.GetManager());
            controllers.ToList().ForEach(c => ControllerContainerInitializer.RegisterStringResources(c));
        }
Beispiel #3
0
        /// <summary>
        /// Uninitializes the controllers that are available to the web application.
        /// </summary>
        public virtual void Uninitialize()
        {
            this.RegisterStringResources();

            this.UninitializeGlobalFilters();

            foreach (var assembly in this.ControllerContainerAssemblies)
            {
                this.UninitializeControllerContainer(assembly);
            }

            this.ControllerContainerAssemblies = null;

            // Clears all controllers
            foreach (var ctrl in ControllerStore.Controllers().ToList())
            {
                ControllerStore.RemoveController(ctrl.ControllerType);
            }

            var sitefinityViewEngines = ViewEngines.Engines.Where(v => v != null && v.GetType() == typeof(CompositePrecompiledMvcEngineWrapper)).ToList();

            foreach (var sitefinityViewEngine in sitefinityViewEngines)
            {
                ViewEngines.Engines.Remove(sitefinityViewEngine);
            }

            var sitefinityViewEngineExists = ViewEngines.Engines.Any(v => v.GetType() == typeof(SitefinityViewEngine));

            if (!sitefinityViewEngineExists)
            {
                // add Sitefinity view engine
                ViewEngines.Engines.Add(new SitefinityViewEngine());
            }
        }
Beispiel #4
0
        public void RegisterController_DesignerController_NotRegistersAnyRoutes()
        {
            // Arrange
            var  initializer = new DummyControllerContainerInitializer();
            Type controller  = typeof(DesignerController);

            using (new ObjectFactoryContainerRegion())
            {
                ObjectFactory.Container.RegisterType <ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name));

                ObjectFactory.Container.RegisterType <XmlConfigProvider, DummyConfigProvider>();

                // Act
                initializer.RegisterControllerPublic(controller);
            }

            // Assert
            ControllerInfo registration = ControllerStore.Controllers().SingleOrDefault(c => c.ControllerType == controller);

            Assert.IsNotNull(registration, "DesignerController was not registered.");

            RouteBase route = RouteTable.Routes[controller.Name];

            Assert.IsNull(route, "Route was registered for the controller.");
        }
Beispiel #5
0
        /// <summary>
        /// Registers the controller so its views and resources can be resolved.
        /// </summary>
        /// <param name="controller">The controller.</param>
        protected virtual void RegisterController(Type controller)
        {
            var controllerStore = new ControllerStore();
            var configManager   = ConfigManager.GetManager();

            using (var modeRegion = new ElevatedConfigModeRegion())
            {
                controllerStore.AddController(controller, configManager);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Registers the controller so its views and resources can be resolved.
        /// </summary>
        /// <param name="controller">The controller.</param>
        protected virtual void RegisterController(Type controller)
        {
            var controllerStore = new ControllerStore();
            var configManager   = ConfigManager.GetManager();

            using (new ElevatedConfigModeRegion())
            {
                this.RegisterStringResources(controller);
                controllerStore.AddController(controller, configManager);
            }
        }
        /// <summary>
        /// Uninitializes the controllers that are available to the web application.
        /// </summary>
        public virtual void Uninitialize()
        {
            this.RegisterStringResources();

            this.UninitializeGlobalFilters();

            foreach (var assembly in this.ControllerContainerAssemblies)
            {
                this.UninitializeControllerContainer(assembly);
            }

            this.ControllerContainerAssemblies = null;

            // Clears all controllers
            foreach (var ctrl in ControllerStore.Controllers().ToList())
            {
                ControllerStore.RemoveController(ctrl.ControllerType);
            }
        }
Beispiel #8
0
        private static Tuple <bool, string> WidgetValidating(string widgetType)
        {
            Tuple <bool, string> widgetState = null;

            var isFeatherWidget = widgetType.StartsWith("Telerik.Sitefinity.Frontend", StringComparison.Ordinal);

            if (isFeatherWidget)
            {
                var featherModule = SystemManager.GetModule("Feather");
                if (featherModule == null)
                {
                    var isActive = ControllerStore.Controllers().Any(c => c.ControllerType != null && c.ControllerType.FullName == widgetType);
                    if (!isActive)
                    {
                        widgetState = new Tuple <bool, string>(false, "Feather");
                    }
                }
            }

            return(widgetState);
        }
Beispiel #9
0
        private string GetWidgetName(ControllerContext context)
        {
            var controllerType = context.Controller.GetType();

            // Check in controller store
            var controllerInfo = ControllerStore.Controllers()
                                 .FirstOrDefault(c => c.ControllerType == controllerType);

            if (controllerInfo != null && !controllerInfo.DefaultToolboxItemTitle.IsNullOrEmpty())
            {
                return(controllerInfo.DefaultToolboxItemTitle);
            }

            // Check for dynamic type
            var modelProperty = controllerType.GetProperty("Model");

            if (modelProperty != null)
            {
                var model = modelProperty.GetValue(context.Controller) as ContentModelBase;
                if (model != null)
                {
                    var contentType = model.ContentType;
                    var manager     = ModuleBuilderManager.GetManager().Provider;
                    var dynamicType = manager.GetDynamicModuleTypes().FirstOrDefault(t => t.TypeName == contentType.Name && t.TypeNamespace == contentType.Namespace);
                    if (dynamicType != null)
                    {
                        return(dynamicType.DisplayName);
                    }
                }
            }

            if (this.ViewPath.StartsWith(CompilationPerformanceRazorView.LayoutVirtualPathBeginning, StringComparison.OrdinalIgnoreCase))
            {
                return(CompilationPerformanceRazorView.Layout);
            }

            var controllerName = FrontendManager.ControllerFactory.GetControllerName(controllerType);

            return(controllerName);
        }
Beispiel #10
0
 /// <summary>
 /// Checks whether after unloading/uninstalling Feather the ControllerStore AddController calls are undone.
 /// </summary>
 private void Check_ControllerStore_AddController_ShouldBeUndone()
 {
     Assert.IsFalse(ControllerStore.Controllers().Any(c => c.ControllerType.FullName.StartsWith(ModuleUnloadTests.FrontendAssemblyPrefix, StringComparison.Ordinal)));
 }
        /// <summary>
        /// Registers the controller so its views and resources can be resolved.
        /// </summary>
        /// <param name="controller">The controller.</param>
        protected virtual void RegisterController(Type controller)
        {
            var controllerStore = new ControllerStore();
            var configManager = ConfigManager.GetManager();

            using (var modeRegion = new ElevatedConfigModeRegion())
            {
                this.RegisterStringResources(controller);
                controllerStore.AddController(controller, configManager);
            }
        }
Beispiel #12
0
    public override void Awake()
    {
        base.Awake();

        Instance = this;
    }