Пример #1
0
        public static JsonSerializerSettings ConfigureArkDefaults(this JsonSerializerSettings @this)
        {
            @this.TypeNameHandling       = TypeNameHandling.None;
            @this.ObjectCreationHandling = ObjectCreationHandling.Replace;
            @this.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
            @this.ConfigureForNodaTimeRanges();
            @this.Converters.Add(new StringEnumConverter());
            @this.ContractResolver = new CamelCasePropertyNamesContractResolver();

            return(@this);
        }
Пример #2
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "main",
                routeTemplate: "1/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseWebApi(config);

            // Configure the JSON serialization settings used throughout the app.
            var serializerSettings = new JsonSerializerSettings();
            serializerSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
            JsonConvert.DefaultSettings = () => serializerSettings;
            config.Formatters.JsonFormatter.SerializerSettings = serializerSettings;

            // Remove model validation to avoid an infinte recursion when
            // using LocalTime in a request.
            // http://stackoverflow.com/a/16701145/19818
            config.Services.Clear(typeof(ModelValidatorProvider));
        }
Пример #3
0
 static JsonAssertions()
 {
     SerializerSettings = new JsonSerializerSettings();
         SerializerSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
 }