Exemple #1
0
 public static IMvcBuilder AddPlainTextFormatters(this IMvcBuilder builder, PlainTextFormatterOptions formatterOptions)
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     return(builder.AddPlainTextInputFormatter(formatterOptions).AddPlainTextOutputFormatter(formatterOptions));
 }
 public static IMvcBuilder AddPlainTextOutputFormatter(this IMvcBuilder builder, PlainTextFormatterOptions formatterOptions)
 {
     if (builder == null) throw new ArgumentNullException(nameof(builder));
     return builder.AddMvcOptions(opts =>
     {
         opts.OutputFormatters.RemoveType<StringOutputFormatter>();
         opts.OutputFormatters.Add(new PlainTextOutputFormatter(formatterOptions));
     });
 }
Exemple #3
0
        public static IMvcBuilder AddPlainTextFormatters(this IMvcBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            var formatterOptions = new PlainTextFormatterOptions();

            return(builder.AddPlainTextFormatters(formatterOptions));
        }
        public PlainTextInputFormatter(PlainTextFormatterOptions opts)
        {
            foreach (var enc in opts.SupportedEncodings)
            {
                SupportedEncodings.Add(enc);
            }

            foreach (var mediaType in opts.SupportedMediaTypes)
            {
                SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(mediaType));
            }
        }
Exemple #5
0
        public PlainTextInputFormatter(PlainTextFormatterOptions opts)
        {
            foreach (var enc in opts.SupportedEncodings)
            {
                SupportedEncodings.Add(enc);
            }

            foreach (var mediaType in opts.SupportedMediaTypes)
            {
                SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse(mediaType));
            }
        }
Exemple #6
0
 public static IMvcBuilder AddPlainTextOutputFormatter(this IMvcBuilder builder, PlainTextFormatterOptions formatterOptions)
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     return(builder.AddMvcOptions(opts =>
     {
         opts.OutputFormatters.RemoveType <StringOutputFormatter>();
         opts.OutputFormatters.Add(new PlainTextOutputFormatter(formatterOptions));
     }));
 }
 public static IMvcBuilder AddPlainTextFormatters(this IMvcBuilder builder)
 {
     if (builder == null) throw new ArgumentNullException(nameof(builder));
     var formatterOptions = new PlainTextFormatterOptions();
     return builder.AddPlainTextFormatters(formatterOptions);
 }
 public static IMvcBuilder AddPlainTextInputFormatter(this IMvcBuilder builder, PlainTextFormatterOptions formatterOptions)
 {
     if (builder == null) throw new ArgumentNullException(nameof(builder));
     return builder.AddMvcOptions(opts => opts.InputFormatters.Add(new PlainTextInputFormatter(formatterOptions)));
 }
 public static IMvcBuilder AddPlainTextFormatters(this IMvcBuilder builder, PlainTextFormatterOptions formatterOptions)
 {
     if (builder == null) throw new ArgumentNullException(nameof(builder));
     return builder.AddPlainTextInputFormatter(formatterOptions).AddPlainTextOutputFormatter(formatterOptions);
 }