예제 #1
0
        public ViewAccountant(ILocalFileProvider localFileProvider, IThemeProvider themeProvider, IMinifier minifier)
        {
            _localFileProvider   = localFileProvider;
            _themeProvider       = themeProvider;
            _minifier            = minifier;
            _parsedTemplateCache = new ConcurrentDictionary <CachedViewKey, CachedView>();

            //set the file system
            Template.FileSystem = new AppThemeFileSystem(this);
            //naming convention camelCaseConvention
            Template.NamingConvention = new CamelCaseNamingConvention();
            //register additional types
            Template.RegisterSafeType(typeof(SelectListItem), new[] { "Text", "Value", "Selected" });

            //register all the enums
            var enumTypes = TypeFinder.EnumTypes();

            foreach (var enumType in enumTypes)
            {
                Template.RegisterSafeType(enumType, x => x.ToString());
            }

            Template.RegisterFilter(typeof(TextFilters));
            Template.RegisterTag <Increment>("increment");
            //register global objects
            GlobalObject.RegisterObject <StoreObject>(GlobalObjectKeys.Store);
            GlobalObject.RegisterObject <CartObject>(GlobalObjectKeys.Cart);
            GlobalObject.RegisterObject <BreadcrumbObject>(GlobalObjectKeys.Breadcrumb);
            GlobalObject.RegisterObject <NavigationObject>(GlobalObjectKeys.Navigation);
            GlobalObject.RegisterObject <CurrentUserObject>(GlobalObjectKeys.CurrentUser);
        }