public EmbeddedViewVirtualPathProvider(EmbeddedViewTable table) {
            if (table == null) {
                throw new ArgumentNullException("table", "EmbeddedViewTable cannot be null.");
            }

            embeddedViews = table;
        }
Ejemplo n.º 2
0
        public EmbeddedViewTable GetEmbeddedViews()
        {
            Assembly[] assemblies = GetAssemblies();
            if (assemblies == null || assemblies.Length == 0)
            {
                return(null);
            }

            var table = new EmbeddedViewTable();

            foreach (var assembly in assemblies)
            {
                var names = GetNamesOfAssemblyResources(assembly);
                if (names == null || names.Length == 0)
                {
                    continue;
                }

                foreach (var name in names)
                {
                    var key = name.ToLowerInvariant();
                    if (!key.Contains(".views."))
                    {
                        continue;
                    }

                    table.AddView(name, assembly.FullName);
                }
            }

            return(table);
        }
        public EmbeddedViewVirtualPathProvider(EmbeddedViewTable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table", "EmbeddedViewTable cannot be null.");
            }

            embeddedViews = table;
        }
Ejemplo n.º 4
0
        public override void Spin(IRotorContext context)
        {
            IServiceLocator       serviceLocator = GetServiceLocatorFromContext(context);
            IEmbeddedViewResolver resolver       = GetEmbeddedViewResolver(serviceLocator);

            EmbeddedViewTable table = resolver.GetEmbeddedViews();

            var embeddedProvider = new EmbeddedViewVirtualPathProvider(table);

            HostingEnvironment.RegisterVirtualPathProvider(embeddedProvider);
        }
        public EmbeddedViewTable GetEmbeddedViews() {
            Assembly[] assemblies = GetAssemblies();
            if (assemblies == null || assemblies.Length == 0) return null;

            var table = new EmbeddedViewTable();

            foreach (var assembly in assemblies) {
                var names = GetNamesOfAssemblyResources(assembly);
                if (names == null || names.Length == 0) continue;

                foreach (var name in names) {
                    var key = name.ToLowerInvariant();
                    if (!key.Contains(".views.")) continue;

                    table.AddView(name, assembly.FullName);
                }
            }

            return table;
        }