/// <summary> /// Registers the types and resolvers related to the layouts functionality. /// </summary> public virtual void Initialize() { ObjectFactory.Container.RegisterType <ILayoutResolver, LayoutResolver>(new ContainerControlledLifetimeManager()); ObjectFactory.Container.RegisterType <IVirtualFileResolver, LayoutMvcPageResolver>("PureMvcPageResolver", new ContainerControlledLifetimeManager(), new InjectionConstructor()); VirtualPathManager.AddVirtualFileResolver <LayoutVirtualFileResolver>(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}{2}", "~/", LayoutVirtualFileResolver.ResolverPath, "*"), typeof(LayoutVirtualFileResolver).FullName); }
public void GetVirtualPath_IPageTemplate_ReturnsNull() { //Arrange LayoutResolver resolver = new LayoutResolver(); DummyFrameworkSpecificPageTemplate dummyPageTemplate = new DummyFrameworkSpecificPageTemplate(PageTemplateFramework.Mvc); using (var objFactory = new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType <ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType <XmlConfigProvider, DummyConfigProvider>(); Config.RegisterSection <VirtualPathSettingsConfig>(); Config.RegisterSection <ControlsConfig>(); VirtualPathManager.AddVirtualFileResolver <DummyVirtualFileResolver>(LayoutResolverTests.testVp, "DummyVirtualFileResolver"); //Act try { var resolvedVirtualPath = resolver.GetVirtualPath(dummyPageTemplate); //Assert Assert.IsNull(resolvedVirtualPath, "Resolved VirtualPath should be null."); } finally { VirtualPathManager.RemoveVirtualFileResolver(LayoutResolverTests.testVp); } } }
public void GetVirtualPath_InvalidCharacters_ReturnsCleanVirtualPath() { //Arrange string dirtyTitle = "Some<>*Test:?Title"; string cleanVirtualPath = "~/SfLayouts/Some_Test_Title.master"; string resolvedVirtualPath; LayoutResolver resolver = new LayoutResolver(); using (var objFactory = new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType <ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType <XmlConfigProvider, DummyConfigProvider>(); Config.RegisterSection <VirtualPathSettingsConfig>(); Config.RegisterSection <ControlsConfig>(); VirtualPathManager.AddVirtualFileResolver <DummyVirtualFileResolver>(LayoutResolverTests.testVp, "DummyVirtualFileResolver"); var dummyPageTemplate = new DummyPageTemplateWithTitle(PageTemplateFramework.Mvc, dirtyTitle); //Act try { resolvedVirtualPath = resolver.GetVirtualPath(dummyPageTemplate); //Assert Assert.AreEqual(cleanVirtualPath, resolvedVirtualPath, "GetVirtualPath method doesn't return correct string."); } finally { VirtualPathManager.RemoveVirtualFileResolver(LayoutResolverTests.testVp); } } }
/// <summary> /// Registers the types and resolvers related to the layouts functionality. /// </summary> public virtual void Initialize() { ObjectFactory.Container.RegisterType <ILayoutResolver, LayoutResolver>(new ContainerControlledLifetimeManager()); VirtualPathManager.AddVirtualFileResolver <LayoutVirtualFileResolver>("~/" + LayoutVirtualFileResolver.ResolverPath + "*", typeof(LayoutVirtualFileResolver).FullName); }
private static void Bootstrapper_Initialized(object sender, ExecutedEventArgs e) { if (e.CommandName == "Bootstrapped") { VirtualPathManager.AddVirtualFileResolver <FormsVirtualRazorResolver>(FormsVirtualRazorResolver.Path + "*", "MvcFormsResolver"); Initializer.UnregisterTemplatableControl(); Initializer.AddFieldsToToolbox(); } }
private void RegisterAssemblyPaths(Assembly assembly) { var assemblyName = assembly.GetName(); var virtualPath = FrontendManager.VirtualPathBuilder.GetVirtualPath(assembly); VirtualPathManager.AddVirtualFileResolver <ResourceResolver>("~/" + virtualPath + "*", assemblyName.Name, assemblyName.CodeBase); SystemManager.RegisterRoute(assemblyName.Name, new Route(virtualPath + "{*Params}", new RouteHandler <ResourceHttpHandler>()), assemblyName.Name, requireBasicAuthentication: false); }
/// <summary> /// Registers the types and resolvers related to the layouts functionality. /// </summary> public virtual void Initialize() { ObjectFactory.Container.RegisterType <ILayoutResolver, LayoutResolver>(new ContainerControlledLifetimeManager()); ObjectFactory.Container.RegisterType <IVirtualFileResolver, LayoutMvcPageResolver>("PureMvcPageResolver", new ContainerControlledLifetimeManager(), new InjectionConstructor()); VirtualPathManager.AddVirtualFileResolver <LayoutVirtualFileResolver>(string.Format(System.Globalization.CultureInfo.InvariantCulture, "~/{0}*", LayoutVirtualFileResolver.ResolverPath), typeof(LayoutVirtualFileResolver).FullName); ObjectFactory.Container.RegisterType <PageRouteHandler, MvcPageRouteHandler>(); ObjectFactory.Container.RegisterType <PageEditorRouteHandler, MvcPageEditorRouteHandler>(); ObjectFactory.Container.RegisterType <TemplateEditorRouteHandler, MvcTemplateEditorRouteHandler>(); System.Web.Routing.RouteTable.Routes.Insert(1, new System.Web.Routing.Route("Sitefinity/Versioning/{itemId}/{VersionNumber}", ObjectFactory.Resolve <MvcVersioningRouteHandler>())); }
public void PopulateScriptReferences_ViewsCollection_ConstructScriptReferencesCollection() { // TODO: Reduce class coupling // Arrange string widgetName = "Dummy"; var views = new List <string>(); views.Add("DesignerView.someViewName"); var designerViewConfigs = this.CreateDummyDesignerViewConfigModel(); using (var objFactory = new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType <ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType <XmlConfigProvider, DummyConfigProvider>(); Config.RegisterSection <VirtualPathSettingsConfig>(); Config.RegisterSection <ControlsConfig>(); Config.RegisterSection <ResourcesConfig>(); using (var factoryReg = new ControllerFactoryRegion <DummyControllerFactory>()) { factoryReg.Factory.ControllerRegistry["Dummy"] = typeof(DummyController); factoryReg.Factory.ControllerRegistry["Designer"] = typeof(DesignerController); var fileResolverPrefix = "~/Frontend-Assembly"; VirtualPathManager.AddVirtualFileResolver <DummyVirtualFileResolver>(fileResolverPrefix + "*", "DummyVirtualFileResolver"); var dummyModel = new DummyDesignerModel(views, new List <string>(), widgetName, Guid.Empty, "someViewName"); try { // Act dummyModel.PopulateScriptReferencesPublic(widgetName, designerViewConfigs); } finally { VirtualPathManager.RemoveVirtualFileResolver(fileResolverPrefix); VirtualPathManager.Reset(); } // Assert Assert.AreEqual(4, dummyModel.ScriptReferences.Count(), "The script count is not as expected."); Assert.IsTrue(dummyModel.ScriptReferences.Contains("Mvc/Scripts/Dummy/designerview-someviewname.js"), "ScriptReferences doesn't contain scripts for the view."); Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script1), "ScriptReferences doesn't contain expected scripts."); Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script2), "ScriptReferences doesn't contain expected scripts."); Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script3), "ScriptReferences doesn't contain expected scripts."); } } }
private void RegisterAssemblyPaths(Assembly assembly) { var assemblyName = assembly.GetName(); var virtualPath = FrontendManager.VirtualPathBuilder.GetVirtualPath(assembly); VirtualPathManager.AddVirtualFileResolver <ResourceResolver>( string.Format(CultureInfo.InvariantCulture, "~/{0}*", virtualPath), assemblyName.Name, assemblyName.CodeBase); SystemManager.RegisterRoute( assemblyName.Name, new Route( virtualPath + "{*Params}", new GenericRouteHandler <ResourceHttpHandler>(() => new ResourceHttpHandler(virtualPath))), assemblyName.Name, requireBasicAuthentication: false); }