/// <summary> /// Initializes a new instance of the <see cref="RendererSettings"/> class. /// </summary> /// <param name="valueGetters">The value getters</param> /// <param name="truthyChecks">The truthy checks</param> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="renderSettings">The render settings</param> /// <param name="enumerationConverters">The enumeration converters</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="rendererPipeline">The renderer pipeline to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> /// <param name="sectionBlacklistTypes">The blacklisted section types</param> /// <param name="encodingFunction">A function for encoding strings</param> public RendererSettings( Dictionary <Type, ValueGetterDelegate> valueGetters, Dictionary <Type, List <Func <object, bool> > > truthyChecks, IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, RenderSettings renderSettings, Dictionary <Type, Func <object, IEnumerable> > enumerationConverters, bool ignoreCaseOnLookup, IMustacheParser parser, TokenRendererPipeline <Context> rendererPipeline, Tags defaultTags, ParserPipeline parserPipeline, HashSet <Type> sectionBlacklistTypes, Func <string, string> encodingFunction) : base( templateLoader, partialLoader, maxRecursionDepth, ignoreCaseOnLookup, parser, defaultTags, parserPipeline, sectionBlacklistTypes) { OrderedValueGetters = valueGetters.Keys.OrderBy(t => t, TypeBySubclassAndAssignableImpl.Default).ToImmutableArray(); ValueGetters = valueGetters.ToImmutableDictionary(); TruthyChecks = truthyChecks.ToImmutableDictionary(k => k.Key, v => v.Value.ToImmutableArray()); RenderSettings = renderSettings; EnumerationConverters = enumerationConverters.ToImmutableDictionary(); RendererPipeline = rendererPipeline; EncodingFuction = encodingFunction; }
/// <summary> /// Initializes a new instance of the <see cref="RendererSettings"/> class. /// </summary> /// <param name="valueGetters">The value getters</param> /// <param name="truthyChecks">The truthy checks</param> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="renderSettings">The render settings</param> /// <param name="enumerationConverters">The enumeration converters</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="rendererPipeline">The renderer pipeline to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> public RendererSettings( Dictionary <Type, Func <object, string, object> > valueGetters, IEnumerable <Func <object, bool?> > truthyChecks, IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, RenderSettings renderSettings, Dictionary <Type, Func <object, IEnumerable> > enumerationConverters, bool ignoreCaseOnLookup, IMustacheParser parser, TokenRendererPipeline rendererPipeline, Classes.Tags defaultTags, ParserPipeline parserPipeline) { ValueGetters = valueGetters.ToImmutableDictionary(); TruthyChecks = truthyChecks.ToImmutableArray(); TemplateLoader = templateLoader; PartialTemplateLoader = partialLoader; MaxRecursionDepth = maxRecursionDepth; RenderSettings = renderSettings; EnumerationConverters = enumerationConverters.ToImmutableDictionary(); IgnoreCaseOnKeyLookup = ignoreCaseOnLookup; Parser = parser; RendererPipeline = rendererPipeline; DefaultTags = defaultTags; ParserPipeline = parserPipeline; }
/// <summary> /// Initializes a new instance of the <see cref="RendererSettings"/> class. /// </summary> /// <param name="valueGetters">The value getters</param> /// <param name="truthyChecks">The truthy checks</param> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="renderSettings">The render settings</param> /// <param name="enumerationConverters">The enumeration converters</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="rendererPipeline">The renderer pipeline to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> public RendererSettings( Dictionary <Type, ValueGetterDelegate> valueGetters, Dictionary <Type, List <Func <object, bool> > > truthyChecks, IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, RenderSettings renderSettings, Dictionary <Type, Func <object, IEnumerable> > enumerationConverters, bool ignoreCaseOnLookup, IMustacheParser parser, TokenRendererPipeline <Context> rendererPipeline, Classes.Tags defaultTags, ParserPipeline parserPipeline) : base( templateLoader, partialLoader, maxRecursionDepth, ignoreCaseOnLookup, parser, defaultTags, parserPipeline) { ValueGetters = valueGetters.ToImmutableDictionary(); TruthyChecks = truthyChecks.ToImmutableDictionary(k => k.Key, v => v.Value.ToImmutableArray()); RenderSettings = renderSettings; EnumerationConverters = enumerationConverters.ToImmutableDictionary(); RendererPipeline = rendererPipeline; }
/// <summary> /// Adds a new loader to the composite loader. /// </summary> /// <param name="loader">The loader to add</param> /// <returns>The composite loader instance</returns> public CompositeLoader AddLoader(IStubbleLoader loader) { if (loader == null) { throw new ArgumentNullException(nameof(loader)); } Loaders.Add(loader); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="Context"/> class. /// </summary> /// <param name="view">The data view to create the context with</param> /// <param name="rendererSettings">A reference to the a registry instance</param> /// <param name="partialLoader">A reference to loader for partials</param> /// <param name="parentContext">The parent context for the new context</param> /// <param name="settings">The render settings </param> public Context(object view, RendererSettings rendererSettings, IStubbleLoader partialLoader, Context parentContext, RenderSettings settings) : base(partialLoader, parentContext) { this.view = view; View = this.view; RendererSettings = rendererSettings; RenderSettings = settings; Cache = new Dictionary <string, object>() { { ".", TryEnumerationConversionIfRequired(this.view) } }; }
private TBuilder CombineLoaders(ref IStubbleLoader currentLoader, IStubbleLoader loader) { if (currentLoader is CompositeLoader compositeLoader) { var composite = compositeLoader; composite.AddLoader(loader); } else { var composite = new CompositeLoader(currentLoader, loader); currentLoader = composite; } return((TBuilder)this); }
/// <summary> /// Initializes a new instance of the <see cref="BaseSettings"/> class. /// </summary> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> public BaseSettings( IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, bool ignoreCaseOnLookup, IMustacheParser parser, Classes.Tags defaultTags, ParserPipeline parserPipeline) { TemplateLoader = templateLoader; PartialTemplateLoader = partialLoader; MaxRecursionDepth = maxRecursionDepth; IgnoreCaseOnKeyLookup = ignoreCaseOnLookup; Parser = parser; DefaultTags = defaultTags; ParserPipeline = parserPipeline; }
/// <summary> /// Initializes a new instance of the <see cref="BaseSettings"/> class. /// </summary> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> /// <param name="sectionBlacklistTypes">The blacklisted section types</param> public BaseSettings( IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, bool ignoreCaseOnLookup, IMustacheParser parser, Classes.Tags defaultTags, ParserPipeline parserPipeline, HashSet <Type> sectionBlacklistTypes) { TemplateLoader = templateLoader; PartialTemplateLoader = partialLoader; MaxRecursionDepth = maxRecursionDepth; IgnoreCaseOnKeyLookup = ignoreCaseOnLookup; Parser = parser; DefaultTags = defaultTags; ParserPipeline = parserPipeline; SectionBlacklistTypes = sectionBlacklistTypes.ToImmutableHashSet(); }
/// <summary> /// Initializes a new instance of the <see cref="CompilerSettings"/> class. /// </summary> /// <param name="valueGetters">The value getters</param> /// <param name="truthyChecks">The truthy checks</param> /// <param name="enumerationConverters">The enumeration converters</param> /// <param name="rendererPipeline">The renderer pipeline to use</param> /// <param name="templateLoader">The template loader</param> /// <param name="partialLoader">The partial loader</param> /// <param name="maxRecursionDepth">The max recursion depth</param> /// <param name="ignoreCaseOnLookup">Should case be ignored on lookup</param> /// <param name="parser">The mustache parser to use</param> /// <param name="defaultTags">The default tags to use during parsing</param> /// <param name="parserPipeline">The parser pipeline to use during parsing</param> /// <param name="compilationSettings">The default compilation settings for each render</param> public CompilerSettings( Dictionary <Type, DefaultSettings.ValueGetterDelegate> valueGetters, Dictionary <Type, List <LambdaExpression> > truthyChecks, Dictionary <Type, EnumerationConverter> enumerationConverters, TokenRendererPipeline <CompilerContext> rendererPipeline, IStubbleLoader templateLoader, IStubbleLoader partialLoader, uint maxRecursionDepth, bool ignoreCaseOnLookup, IMustacheParser parser, Tags defaultTags, ParserPipeline parserPipeline, CompilationSettings compilationSettings) : base(templateLoader, partialLoader, maxRecursionDepth, ignoreCaseOnLookup, parser, defaultTags, parserPipeline) { ValueGetters = valueGetters.ToImmutableDictionary(); TruthyChecks = truthyChecks.ToImmutableDictionary(k => k.Key, v => v.Value.ToImmutableList()); EnumerationConverters = enumerationConverters.ToImmutableDictionary(); RendererPipeline = rendererPipeline; CompilationSettings = compilationSettings; }
/// <inheritdoc/> public IStubbleBuilder <T> AddToTemplateLoader(IStubbleLoader loader) { SettingsBuilder.AddToTemplateLoader(loader); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="Context"/> class. /// </summary> /// <param name="view">The data view to create the context with</param> /// <param name="rendererSettings">A reference to the a registry instance</param> /// <param name="partialLoader">A reference to loader for partials</param> /// <param name="settings">The render settings </param> public Context(object view, RendererSettings rendererSettings, IStubbleLoader partialLoader, RenderSettings settings) : this(view, rendererSettings, partialLoader, null, settings) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseContext{TContext}"/> class. /// </summary> /// <param name="partialLoader">A reference to loader for partials</param> /// <param name="parentContext">The parent context for the new context</param> public BaseContext(IStubbleLoader partialLoader, TContext parentContext) { ParentContext = parentContext; PartialLoader = partialLoader; }
/// <summary> /// Adds a loader to the Template Loader. If the Template Loader is a <see cref="CompositeLoader"/> then /// the loader is added. If not then the Template Loader is updated with a <see cref="CompositeLoader"/> /// combining the Template Loader and loader parameter. /// </summary> /// <param name="loader">The loader to add to the Template Loader</param> /// <returns>The <see cref="RendererSettingsBuilder"/> for chaining</returns> public TBuilder AddToTemplateLoader(IStubbleLoader loader) { return(CombineLoaders(ref templateLoader, loader.Clone())); }
/// <summary> /// Sets the Partial Template Loader to be the passed loader /// </summary> /// <param name="loader">The loader to set as the Partial Template Loader</param> /// <returns>The <see cref="RendererSettingsBuilder"/> for chaining</returns> public TBuilder SetPartialTemplateLoader(IStubbleLoader loader) { partialTemplateLoader = loader.Clone(); return((TBuilder)this); }
private void SetTemplateLoader(IStubbleLoader loader) { TemplateLoader = loader ?? new StringLoader(); }
private void SetPartialTemplateLoader(IStubbleLoader loader) { PartialTemplateLoader = loader; }
/// <summary> /// Sets the Partial Template Loader to be the passed loader /// </summary> /// <param name="loader">The loader to set as the Partial Template Loader</param> /// <returns>The <see cref="RendererSettingsBuilder"/> for chaining</returns> public RendererSettingsBuilder SetPartialTemplateLoader(IStubbleLoader loader) { partialTemplateLoader = loader.Clone(); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="CompilerContext"/> class. /// </summary> /// <param name="view">The type for the context</param> /// <param name="sourceData">The source expression for the type</param> /// <param name="compilerSettings">The compilation settings</param> /// <param name="partialLoader">A loader for partial templates</param> /// <param name="settings">The compilation settings for the compiler</param> public CompilerContext(Type view, Expression sourceData, CompilerSettings compilerSettings, IStubbleLoader partialLoader, CompilationSettings settings) : this(view, sourceData, compilerSettings, partialLoader, settings, null) { }
/// <inheritdoc/> public IStubbleBuilder <T> SetPartialTemplateLoader(IStubbleLoader loader) { SettingsBuilder.SetPartialTemplateLoader(loader); return(this); }
/// <summary> /// Adds a new loader to the composite loader. /// </summary> /// <param name="loader">The loader to add</param> /// <returns>The composite loader instance</returns> public CompositeLoader AddLoader(IStubbleLoader loader) { loaders.Add(loader); return this; }
/// <summary> /// Initializes a new instance of the <see cref="CompilerContext"/> class with a parent context /// </summary> /// <param name="view">The type for the context</param> /// <param name="sourceData">The source expression for the type</param> /// <param name="compilerSettings">The compilation settings</param> /// <param name="partialLoader">A loader for partial templates</param> /// <param name="settings">The compilation settings for the compiler</param> /// <param name="parentContext">The parent context for the new context</param> public CompilerContext(Type view, Expression sourceData, CompilerSettings compilerSettings, IStubbleLoader partialLoader, CompilationSettings settings, CompilerContext parentContext) : base(partialLoader, parentContext) { CompilerSettings = compilerSettings; CompilationSettings = settings; View = view; SourceData = sourceData; cache = new Dictionary <string, Expression>() { { ".", sourceData } }; }
/// <summary> /// Adds a loader to the Partial Template Loader. If the Partial Template Loader is a <see cref="CompositeLoader"/> then /// the loader is added. If not then the Partial Template Loader is updated with a <see cref="CompositeLoader"/> /// combining the Partial Template Loader and loader parameter. /// </summary> /// <param name="loader">The loader to add to the Partial Template Loader</param> /// <returns>The <see cref="RendererSettingsBuilder"/> for chaining</returns> public RendererSettingsBuilder AddToPartialTemplateLoader(IStubbleLoader loader) { return(CombineLoaders(ref partialTemplateLoader, loader.Clone())); }