Commits

Anonymous committed da5e464

Fixed bug with persisting options throughout the serialization process.

Comments (0)

Files changed (3)

Json.sln.docstates.suo

Binary file modified.
Binary file modified.

Json/Serialization/JsonSerializationTypeRegistry.cs

 		private static readonly JsonSerializer _serializer;
 		private static readonly object lockHolder = new object();
 
-		private static JsonSerializerOptions requestedOptions;
-
 		static JsonSerializationTypeRegistry()
 		{
 			ToJsonConverters = new Dictionary<Type, Delegate>();
 			}
 			lock (lockHolder)
 			{
-				requestedOptions = serializer.Options;
+				_serializer.Options = serializer.Options;
 				json = converter(obj);
-				requestedOptions = null;
 				return true;
 			}
 		}
 			}
 			lock (lockHolder)
 			{
-				requestedOptions = serializer.Options;
+				_serializer.Options = serializer.Options;
 				obj = converter(json);
-				requestedOptions = null;
 				return true;
 			}
 		}
 		/// <returns>The JSON representation of the DateTime.</returns>
 		public static JsonValue EncodeDateTime(DateTime dt)
 		{
-			if (requestedOptions == null)
+			if (_serializer.Options == null)
 				return dt.ToString();
-			switch (requestedOptions.DateTimeSerializationFormat)
+			switch (_serializer.Options.DateTimeSerializationFormat)
 			{
 				case DateTimeSerializationFormat.JavaConstructor:
 					return string.Format("/Date({0})/", dt.Ticks/TimeSpan.TicksPerMillisecond);
 		/// <returns>The DateTime object.</returns>
 		public static DateTime DecodeDateTime(JsonValue json)
 		{
-			if (requestedOptions == null)
+			if (_serializer.Options == null)
 				return DateTime.Parse(json.String);
-			switch (requestedOptions.DateTimeSerializationFormat)
+			switch (_serializer.Options.DateTimeSerializationFormat)
 			{
 				case DateTimeSerializationFormat.JavaConstructor:
 					return new DateTime(long.Parse(json.String.Substring(6, json.String.Length - 8))*TimeSpan.TicksPerMillisecond);