Exemplo n.º 1
0
        public TemplateContext ScanType(Type type)
        {
            if (!type.IsAbstract)
            {
                if (typeof(TemplateFilter).IsAssignableFrom(type))
                {
                    if (TemplateFilters.All(x => x?.GetType() != type))
                    {
                        Container.AddSingleton(type);
                        var filter = (TemplateFilter)Container.Resolve(type);
                        TemplateFilters.Add(filter);
                    }
                }
                else if (typeof(TemplateBlock).IsAssignableFrom(type))
                {
                    if (TemplateBlocks.All(x => x?.GetType() != type))
                    {
                        Container.AddSingleton(type);
                        var block = (TemplateBlock)Container.Resolve(type);
                        TemplateBlocks.Add(block);
                    }
                }
                else if (typeof(TemplateCodePage).IsAssignableFrom(type))
                {
                    if (CodePages.Values.All(x => x != type))
                    {
                        Container.AddTransient(type);
                        var pageAttr = type.FirstAttribute <PageAttribute>();
                        if (pageAttr?.VirtualPath != null)
                        {
                            CodePages[pageAttr.VirtualPath] = type;
                        }
                    }
                }
            }

            return(this);
        }
Exemplo n.º 2
0
 public TemplateContext RemoveBlocks(Predicate <TemplateBlock> match)
 {
     TemplateBlocks.RemoveAll(match);
     return(this);
 }