/// <summary>
        /// 
        /// </summary>
        /// <param name="appHost"></param>
        public void Register(IAppHost appHost)
        {
            var inMemoryProvider = new RecursiveInMemoryVirtualPathProvider(appHost);
            // Create a "Views" directory for dumping all our discovered views in
            var viewsDir = new InMemoryVirtualDirectory(inMemoryProvider, inMemoryProvider.rootDirectory)
            {
                DirName = "Views",
                files = new List<InMemoryVirtualFile>(),
                dirs = new List<InMemoryVirtualDirectory>()
            };
            inMemoryProvider.rootDirectory.dirs.Add(viewsDir);

            foreach (var asm in _assemblies)
            {
                foreach (string resource in asm.GetManifestResourceNames())
                {
                        // Get just the file name. Internally, ServiceStack dumps all these in a giant "/Views" directory anyway, so let's just do that.
                        string path = string.Join(".", resource.Split('.').Reverse().Take(2).Reverse());
                        viewsDir.AddFile(path, new StreamReader(asm.GetManifestResourceStream(resource)).ReadToEnd());
                }
            }

            var razorPlugin = new RazorFormat
            {
                VirtualPathProvider = inMemoryProvider,
                EnableLiveReload = false
            };

            appHost.LoadPlugin(razorPlugin);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appHost"></param>
        public void Register(IAppHost appHost)
        {
            var inMemoryProvider = new RecursiveInMemoryVirtualPathProvider(appHost);
            // Create a "Views" directory for dumping all our discovered views in
            var viewsDir = new InMemoryVirtualDirectory(inMemoryProvider, inMemoryProvider.rootDirectory)
            {
                DirName = "Views",
                files   = new List <InMemoryVirtualFile>(),
                dirs    = new List <InMemoryVirtualDirectory>()
            };

            inMemoryProvider.rootDirectory.dirs.Add(viewsDir);

            foreach (var asm in _assemblies)
            {
                foreach (string resource in asm.GetManifestResourceNames())
                {
                    // Get just the file name. Internally, ServiceStack dumps all these in a giant "/Views" directory anyway, so let's just do that.
                    string path = string.Join(".", resource.Split('.').Reverse().Take(2).Reverse());
                    viewsDir.AddFile(path, new StreamReader(asm.GetManifestResourceStream(resource)).ReadToEnd());
                }
            }

            var razorPlugin = new RazorFormat
            {
                VirtualPathProvider = inMemoryProvider,
                EnableLiveReload    = false
            };

            appHost.LoadPlugin(razorPlugin);
        }