public HandlebarsConfigurationAdapter(HandlebarsConfiguration configuration) { UnderlingConfiguration = configuration; HelperResolvers = new ObservableList <IHelperResolver>(configuration.HelperResolvers); RegisteredTemplates = new ObservableDictionary <string, Action <TextWriter, object> >(configuration.RegisteredTemplates); PathInfoStore = _pathInfoStore = new PathInfoStore(); ObjectDescriptorProvider = CreateObjectDescriptorProvider(); AliasProviders = new ObservableList <IMemberAliasProvider>(UnderlingConfiguration.AliasProviders); ExpressionMiddleware = new ObservableList <IExpressionMiddleware>(UnderlingConfiguration.CompileTimeConfiguration.ExpressionMiddleware); Features = UnderlingConfiguration.CompileTimeConfiguration.Features .Select(o => o.CreateFeature()) .OrderBy(o => o.GetType().GetTypeInfo().GetCustomAttribute <FeatureOrderAttribute>()?.Order ?? 100) .ToList(); CreateHelpersSubscription(); CreateBlockHelpersSubscription(); AliasProviders.Add(new CollectionMemberAliasProvider(this)); }
public HandlebarsConfigurationAdapter(HandlebarsConfiguration configuration) { UnderlingConfiguration = configuration; HelperResolvers = new ObservableList <IHelperResolver>(configuration.HelperResolvers); RegisteredTemplates = new ObservableDictionary <string, HandlebarsTemplate <TextWriter, object, object> >(configuration.RegisteredTemplates); PathInfoStore = _pathInfoStore = HandlebarsDotNet.PathInfoStore.Shared; ObjectDescriptorProvider = CreateObjectDescriptorProvider(); AliasProviders = new ObservableList <IMemberAliasProvider>(UnderlingConfiguration.AliasProviders); UnresolvedBindingFormat = configuration.UnresolvedBindingFormat ?? (undefined => { var formatter = UnresolvedBindingFormatter; if (formatter == null) { if (string.IsNullOrEmpty(undefined.Value)) { return(string.Empty); } formatter = string.Empty; } return(string.Format(formatter, undefined.Value)); }); ExpressionMiddlewares = new ObservableList <IExpressionMiddleware>(UnderlingConfiguration.CompileTimeConfiguration.ExpressionMiddleware) { new ExpressionOptimizerMiddleware() }; Features = UnderlingConfiguration.CompileTimeConfiguration.Features .Select(o => o.CreateFeature()) .OrderBy(o => o.GetType().GetTypeInfo().GetCustomAttribute <FeatureOrderAttribute>()?.Order ?? 100) .ToList(); CreateHelpersSubscription(); CreateBlockHelpersSubscription(); }