/// <summary>
        /// Builds an instance of the compilation settings from the builder
        /// </summary>
        /// <returns>The built compilation settings</returns>
        public override CompilerSettings BuildSettings()
        {
            var mergedGetters = DefaultSettings.DefaultValueGetters().MergeLeft(ValueGetters);

            return(new CompilerSettings(
                       mergedGetters,
                       TruthyChecks,
                       EnumerationConverters,
                       new TokenRendererPipeline <CompilerContext>(TokenRenderers),
                       TemplateLoader,
                       PartialTemplateLoader,
                       MaxRecursionDepth.HasValue ? (MaxRecursionDepth.Value > 0 ? MaxRecursionDepth.Value : uint.MaxValue) : 256,
                       IgnoreCaseOnKeyLookup,
                       Parser ?? new CachedMustacheParser(),
                       DefaultTags ?? new Core.Classes.Tags("{{", "}}"),
                       ParserPipelineBuilder.Build(),
                       CompilationSettings ?? CompilationSettings.GetDefaultRenderSettings(),
                       SectionBlacklistTypes ?? DefaultSettings.DefaultSectionBlacklistTypes(),
                       EncodingFunction ?? EncodingFunctions.WebUtilityHtmlEncoding));
        }
Esempio n. 2
0
 /// <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;
 }
 /// <summary>
 /// Sets the compilation settings
 /// </summary>
 /// <param name="settings">The settings to use</param>
 /// <returns>The builder instance for chaining</returns>
 public CompilerSettingsBuilder SetCompilationSettings(CompilationSettings settings)
 {
     CompilationSettings = settings;
     return(this);
 }