Exemplo n.º 1
0
        static IHxlTemplateFactory FromAssemblyInternal(Assembly assembly)
        {
            var d = assembly.GetCustomAttributes(typeof(HxlTemplateFactoryAttribute))
                    .Cast <HxlTemplateFactoryAttribute>();

            if (d.Any())
            {
                Traceables.HxTemplateFactoryFromAssemblyExplicit(assembly, d);
                var all = d.Select(t => (IHxlTemplateFactory)Activator.CreateInstance(t.FactoryType));
                return(Compose(all));
            }

            // Default slow implementation
            // Don't scan App_Web assemblies for templates
            // HACK Using the name of the generated assembly (might be better to check for [GeneratedCode] if this works with Mono)
            if (Utility.IsHxlAssembly(assembly) && !assembly.GetName().Name.StartsWith("App_Web_", StringComparison.Ordinal))
            {
                var result = new ReflectedTemplateFactory(assembly);
                Traceables.HxTemplateFactoryFromAssemblySlow(assembly, result);
                return(result);
            }
            else
            {
                Traceables.HxTemplateFactoryFromAssemblySkip(assembly);
                return(HxlTemplateFactory.Null);
            }
        }
Exemplo n.º 2
0
 public static void HxTemplateFactoryFromAssemblySlow(Assembly assembly, ReflectedTemplateFactory result)
 {
     if (log.TraceEnabled)
     {
         log.TraceFormat("Created template factory for assembly {0} (templates: {1}).",
                         assembly.GetName(), result.TemplateCount);
     }
     if (log.DebugEnabled)
     {
         log.DebugFormat("Available templates for {0}: {1}",
                         assembly.GetName(),
                         string.Join("\n  ", result));
     }
 }