public string FindContentInResourse(string viewName, bool throwException = true)
        {
            var assembliesCandidates = AssemblyDiscovery.GetAllLoaded().Where(f => !f.FullName.StartsWith("System") && !f.FullName.StartsWith("Microsoft"));

            foreach (var curAssembly in assembliesCandidates)
            {
                var name = curAssembly
                           .GetManifestResourceNames()
                           .FirstOrDefault(n => n.ToLower().EndsWith(viewName.Replace("/", ".").ToLower()));

                if (name != null)
                {
                    using (var reader = new StreamReader(curAssembly.GetManifestResourceStream(name)))
                    {
                        return(reader.ReadToEnd());
                    }
                }
            }

            if (throwException)
            {
                ThrowFindContentInResourse(viewName);
            }

            return(null);
        }
Exemple #2
0
        public RazorTemplate()
        {
            var curAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            this.referenceManager  = new RazorReferenceManagerImp(AssemblyDiscovery.GetAllLoaded());
            this.compiler          = new CSharpCompiler(this.referenceManager, curAssemblyName, Development.IsAttached);
            this.razorViewExecutor = new RazorViewExecutor();
        }