/// <summary> /// Setups the formatters. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="formatter">The formatter.</param> /// <returns>JsonMediaTypeFormatter.</returns> private static JsonMediaTypeFormatter SetupFormatters(this HttpConfiguration configuration, JsonMediaTypeFormatter formatter = null) { configuration.Formatters.Clear(); var fmt = formatter ?? new JsonMediaTypeFormatter { SerializerSettings = { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Local, ContractResolver = new CamelCasePropertyNamesContractResolver() } }; configuration.Formatters.Add(fmt); var multipartSettings = new MultipartFormatterSettings { CultureInfo = CultureInfo.CurrentCulture, SerializeByteArrayAsHttpFile = true, ValidateNonNullableMissedProperty = true }; configuration.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter(multipartSettings)); return(fmt); }
public ObjectToMultipartDataByteArrayConverter(MultipartFormatterSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } Settings = settings; }
/// <summary> /// Instantiate and initialise a new instance of <see cref="FormDataToObjectConverter"/> /// </summary> /// <param name="sourceData">The <see cref="FormData"/> to convert.</param> /// <param name="logger">The <see cref="IFormatterLogger"/> to log events to.</param> /// <param name="settings">The <see cref="MultipartFormatterSettings"/> to use.</param> public FormDataToObjectConverter(FormData sourceData, IFormDataConverterLogger logger, MultipartFormatterSettings settings) { if (sourceData == null) { throw new ArgumentNullException("sourceData"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (settings == null) { throw new ArgumentNullException("settings"); } _settings = settings; _sourceData = sourceData; _logger = logger; }
public FormMultipartEncodedMediaTypeFormatter(MultipartFormatterSettings settings = null) { Settings = settings ?? new MultipartFormatterSettings(); SupportedMediaTypes.Add(new MediaTypeHeaderValue(SupportedMediaType)); }