Esempio n. 1
0
        /// <summary>
        ///     Override to use a specialized JsonSerializer implementation.
        /// </summary>
        /// <param name="contractResolver">BreezeContractResolver</param>
        private static JsonSerializerSettings CreateJsonSerializerSettings(BreezeContractResolver contractResolver)
        {
            var jsonSerializerSettings = new JsonSerializerSettings
            {
                ContractResolver               = contractResolver,
                NullValueHandling              = NullValueHandling.Include,
                PreserveReferencesHandling     = PreserveReferencesHandling.Objects,
                ReferenceLoopHandling          = ReferenceLoopHandling.Ignore,
                TypeNameHandling               = TypeNameHandling.Objects,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple
            };

            // Default is DateTimeZoneHandling.RoundtripKind - you can change that here.
            // jsonSerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;

            // Hack is for the issue described in this post:
            // http://stackoverflow.com/questions/11789114/internet-explorer-json-net-javascript-date-and-milliseconds-issue
            jsonSerializerSettings.Converters.Add(new IsoDateTimeConverter
            {
                DateTimeFormat = "yyyy-MM-dd\\THH:mm:ss.fffK"
                                 // DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"
            });
            // Needed because JSON.NET does not natively support I8601 Duration formats for TimeSpan
            jsonSerializerSettings.Converters.Add(new TimeSpanConverter());
            jsonSerializerSettings.Converters.Add(new StringEnumConverter());

            return(jsonSerializerSettings);
        }
Esempio n. 2
0
        /// <summary>
        ///     Override to use a specialized JsonSerializer implementation for saving.
        ///     Base implementation uses CreateJsonSerializerSettings, then changes TypeNameHandling to None.
        ///     http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_TypeNameHandling.htm
        /// </summary>
        /// <param name="container"></param>
        private static JsonSerializerSettings CreateJsonSerializerSettingsForSave(BreezeContractResolver contractResolver)
        {
            var settings = CreateJsonSerializerSettings(contractResolver);

            settings.TypeNameHandling = TypeNameHandling.None;

            return(settings);
        }
Esempio n. 3
0
        /// <summary>
        ///     Override to use a specialized JsonSerializer implementation for saving.
        ///     Base implementation uses CreateJsonSerializerSettings, then changes TypeNameHandling to None.
        ///     http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_TypeNameHandling.htm
        /// </summary>
        /// <param name="container"></param>
        private static JsonSerializerSettings CreateJsonSerializerSettingsForSave(BreezeContractResolver contractResolver)
        {
            var settings = CreateJsonSerializerSettings(contractResolver);

            settings.TypeNameHandling = TypeNameHandling.None;
            settings.Converters.Add(new BreezeSavePayloadConverter());

            return(settings);
        }
Esempio n. 4
0
        public BreezeConfig(BreezeContractResolver contractResolver)
        {
            _jsonSerializerSettings        = CreateJsonSerializerSettings(contractResolver);
            _jsonSerializerSettingsForSave = CreateJsonSerializerSettingsForSave(contractResolver);

            AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
            {
                Interlocked.Increment(ref _assemblyLoadedCount);
            };
        }
 public BreezeJsonSerializerSettingsProvider(BreezeContractResolver breezeContractResolver) : base(breezeContractResolver)
 {
 }