Пример #1
0
 public static void Write(this IFormatterMatcher matcher, Func <string> log)
 {
     if (matcher is FormatterMatcher defaultMatcher)
     {
         defaultMatcher.Log(log);
     }
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ParserOptions" /> class.
 /// </summary>
 /// <param name="template">The template.</param>
 /// <param name="sourceStream">The source stream.</param>
 /// <param name="encoding">The encoding.</param>
 public ParserOptions([CanBeNull] string template, Func <Stream> sourceStream, Encoding encoding)
 {
     Template               = template ?? "";
     SourceFactory          = sourceStream ?? (() => new MemoryStream());
     Encoding               = encoding ?? Encoding.UTF8;
     _formatters            = new FormatterMatcher();
     Null                   = string.Empty;
     MaxSize                = 0;
     DisableContentEscaping = false;
     WithModelInference     = false;
     Timeout                = TimeSpan.Zero;
     PartialStackSize       = 255;
 }
Пример #3
0
 /// <summary>
 ///     Adds the formatter.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <typeparam name="TArgument"></typeparam>
 /// <param name="matcher">The instance of FormatterMatcher</param>
 /// <param name="formatterDelegate">The formatter delegate.</param>
 public static FormatTemplateElement AddFormatter <T, TArgument, TResult>(
     this IFormatterMatcher matcher, [NotNull] Func <T, TArgument, TResult> formatterDelegate)
 {
     return(matcher.AddFormatter(typeof(T), formatterDelegate));
 }