Exemple #1
0
        public void AddProfile(RazorProfile profile)
        {
            var pattern = string.Format(@"[\w\.]+\.{0}\.(?<key>[\w\.]+).cshtml", profile.TemplateFolder);
            var regex   = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            var resourceNames = from resourceName in Assembly.GetAssembly(profile.GetType()).GetManifestResourceNames()
                                let match = regex.Match(resourceName)
                                            where match.Success
                                            select new { Key = match.Groups["key"].Value.ToLowerInvariant(), ResourceName = resourceName };

            foreach (var pair in resourceNames)
            {
                _registeredTemplates[pair.Key] = new AssemblyResource
                {
                    Key = pair.Key,
                    DefiningAssembly = profile.DefiningAssembly,
                    ResourceName     = pair.ResourceName
                };
            }
        }
Exemple #2
0
 public void AddProfile(RazorProfile profile)
 {
     _templateService.Configuration.Resolver.AddProfile(profile);
 }