Stores all the embedded resources for a single assembly/area.
        private static Dictionary<string, AssemblyResourceStore> InitializeAssemblyResourceStores()
        {
            var resourceStores = new Dictionary<string, AssemblyResourceStore>();

            // Add default AssemblyResourceStore for input builders
            var inputBuildersStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "/views/inputbuilders", "MvcContrib.UI.InputBuilder.Views.InputBuilders");
            resourceStores.Add(inputBuildersStore.VirtualPath, inputBuildersStore);

            return resourceStores;
        }
        public void The_file_should_locate_a_embedded_resource()
        {
            //arrange
            var resourceStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "", "MvcContrib.UI.InputBuilder");
            var file = new AssemblyResourceVirtualFile("~/Views/InputBuilders/String.aspx", resourceStore);

            //act
            var result = file.Open();

            //assert
            Assert.IsNotNull(result);
        }
        public void The_file_should_not_locate_an_invalid_path()
        {
            //arrange
            var resourceStore = new AssemblyResourceStore(typeof(AssemblyResourceProvider), "", "MvcContrib.UI.InputBuilder");

            var file = new AssemblyResourceVirtualFile("~/foo", resourceStore);

            //act
            var result = file.Open();

            //assert
            Assert.IsNull(result);
        }
Esempio n. 4
0
        public static void BootStrap()
        {
            if (!ViewEngines.Engines.Any(engine => engine.GetType().Equals(typeof(InputBuilderViewEngine))))
            {
                VirtualPathProvider pathProvider = new AssemblyResourceProvider();

                RegisterPathProvider(pathProvider);

                var resourceStore = new AssemblyResourceStore(typeof(PortableAreaRegistration), "/areas", typeof(PortableAreaRegistration).Namespace);
                AssemblyResourceManager.RegisterAreaResources(resourceStore);

                ViewEngines.Engines.Add(new InputBuilderViewEngine(new string[0]));
            }
        }
public void RegisterAreaEmbeddedResources()
{
    var areaType = GetType();
            var resourceStore = new AssemblyResourceStore(areaType, "/areas/" + AreaName.ToLower(), areaType.Namespace, GetMap());
            AssemblyResourceManager.RegisterAreaResources(resourceStore);
}
 public static void RegisterAreaResources(AssemblyResourceStore assemblyResourceStore)
 {
     assemblyResourceStores.Add(assemblyResourceStore.VirtualPath, assemblyResourceStore);
 }
 public AssemblyResourceVirtualFile(string virtualPath, AssemblyResourceStore resourceStore)
     : base(virtualPath)
 {
     this.resourceStore = resourceStore;
     path = VirtualPathUtility.ToAppRelative(virtualPath);
 }
 public AssemblyResourceVirtualFile(string virtualPath, AssemblyResourceStore resourceStore)
     : base(virtualPath)
 {
     this.resourceStore = resourceStore;
     path = VirtualPathUtility.ToAppRelative(virtualPath);
 }