Commits

Anonymous committed f668b4e

Restructured using prinicple of Dependency Injection.
Added enumeration support.
Added JsonArray.OfType() extension method.
Added automatic generation of unspecified interface types.
BUG FIX: Modifying a serializer's options when it used Default could modify Default.

  • Participants
  • Parent commits 6f15337

Comments (0)

Files changed (54)

File Json.Tests/Json/Extensions/JsonArrayExtensionsTest.cs

+/***************************************************************************************
+
+	Copyright 2012 Greg Dennis
+
+	   Licensed under the Apache License, Version 2.0 (the "License");
+	   you may not use this file except in compliance with the License.
+	   You may obtain a copy of the License at
+
+		 http://www.apache.org/licenses/LICENSE-2.0
+
+	   Unless required by applicable law or agreed to in writing, software
+	   distributed under the License is distributed on an "AS IS" BASIS,
+	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	   See the License for the specific language governing permissions and
+	   limitations under the License.
+ 
+	File Name:		JsonArrayExtensionsTest.cs
+	Namespace:		Manatee.Tests.Json.Extensions
+	Class Name:		JsonArrayExtensionsTest
+	Purpose:		Tests for the JsonArray extension methods for the Json library.
+
+***************************************************************************************/
+using Manatee.Json;
+using Manatee.Json.Enumerations;
+using Manatee.Json.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Manatee.Tests.Json.Extensions
+{
+	[TestClass]
+	public class JsonArrayExtensionsTest
+	{
+		[TestMethod]
+		public void OfType_ReturnsOnlyRequestType()
+		{
+			var json = new JsonArray {6, "string", false, 42, JsonValue.Null, true};
+			var expected = new JsonArray {6, 42};
+			var values = json.OfType(JsonValueType.Number);
+
+			Assert.AreEqual(expected, values);
+		}
+	}
+}

File Json.Tests/Json/Extensions/JsonExtensionsTest.cs

-using System;
-using System.Text;
-using System.Collections.Generic;
-using System.Linq;
-using Manatee.Json;
-using Manatee.Json.Extensions;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Extensions
-{
-	[TestClass]
-	public class JsonExtensionsTest
-	{
-		[TestMethod]
-		public void TryGetString_ReturnsRequested()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-
-			var value = json.TryGetString("string");
-
-			Assert.AreEqual("test", value);
-		}
-		[TestMethod]
-		public void TryGetString_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetString("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetString_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-			var value = json.TryGetString("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetString_ValueNotStringReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-			var value = json.TryGetString("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ReturnsRequested()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-
-			var value = json.TryGetNumber("number");
-
-			Assert.AreEqual(6.0, value);
-		}
-		[TestMethod]
-		public void TryGetNumber_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetNumber("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"boolean", true}
-			           	};
-			var value = json.TryGetNumber("number");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetNumber_ValueNotNumberReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-			var value = json.TryGetNumber("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ReturnsRequested()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.AreEqual(true, value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6}
-			           	};
-			var value = json.TryGetBoolean("boolean");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetBoolean_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"boolean", true}
-			           	};
-			var value = json.TryGetBoolean("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ReturnsRequested()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"array", new JsonArray()}
-			           	};
-
-			var value = json.TryGetArray("array");
-
-			Assert.AreEqual(new JsonArray(), value);
-		}
-		[TestMethod]
-		public void TryGetArray_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetArray("array");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6}
-			           	};
-			var value = json.TryGetArray("array");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetArray_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"array", new JsonArray()}
-			           	};
-			var value = json.TryGetArray("string");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ReturnsRequested()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"object", new JsonObject()}
-			           	};
-
-			var value = json.TryGetObject("object");
-
-			Assert.AreEqual(new JsonObject(), value);
-		}
-		[TestMethod]
-		public void TryGetObject_NullObjectReturnsNull()
-		{
-			JsonObject json = null;
-
-			var value = json.TryGetObject("object");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ValueNotFoundReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6}
-			           	};
-			var value = json.TryGetObject("object");
-
-			Assert.IsNull(value);
-		}
-		[TestMethod]
-		public void TryGetObject_ValueNotBooleanReturnsNull()
-		{
-			var json = new JsonObject
-			           	{
-			           		{"string", "test"},
-			           		{"number", 6},
-			           		{"object", new JsonObject()}
-			           	};
-			var value = json.TryGetObject("string");
-
-			Assert.IsNull(value);
-		}
-	}
-}

File Json.Tests/Json/Extensions/JsonObjectExtensionsTest.cs

+/***************************************************************************************
+
+	Copyright 2012 Greg Dennis
+
+	   Licensed under the Apache License, Version 2.0 (the "License");
+	   you may not use this file except in compliance with the License.
+	   You may obtain a copy of the License at
+
+		 http://www.apache.org/licenses/LICENSE-2.0
+
+	   Unless required by applicable law or agreed to in writing, software
+	   distributed under the License is distributed on an "AS IS" BASIS,
+	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	   See the License for the specific language governing permissions and
+	   limitations under the License.
+ 
+	File Name:		JsonObjectExtensionsTest.cs
+	Namespace:		Manatee.Tests.Json.Extensions
+	Class Name:		JsonObjectExtensionsTest
+	Purpose:		Tests for the JsonObject extension methods for the Json library.
+
+***************************************************************************************/
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json;
+using Manatee.Json.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Manatee.Tests.Json.Extensions
+{
+	[TestClass]
+	public class JsonObjectExtensionsTest
+	{
+		[TestMethod]
+		public void TryGetString_ReturnsRequested()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+
+			var value = json.TryGetString("string");
+
+			Assert.AreEqual("test", value);
+		}
+		[TestMethod]
+		public void TryGetString_NullObjectReturnsNull()
+		{
+			JsonObject json = null;
+
+			var value = json.TryGetString("string");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetString_ValueNotFoundReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"number", 6},
+					{"boolean", true}
+				};
+			var value = json.TryGetString("string");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetString_ValueNotStringReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+			var value = json.TryGetString("number");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetNumber_ReturnsRequested()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+
+			var value = json.TryGetNumber("number");
+
+			Assert.AreEqual(6.0, value);
+		}
+		[TestMethod]
+		public void TryGetNumber_NullObjectReturnsNull()
+		{
+			JsonObject json = null;
+
+			var value = json.TryGetNumber("number");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetNumber_ValueNotFoundReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"boolean", true}
+				};
+			var value = json.TryGetNumber("number");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetNumber_ValueNotNumberReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+			var value = json.TryGetNumber("string");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetBoolean_ReturnsRequested()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+
+			var value = json.TryGetBoolean("boolean");
+
+			Assert.AreEqual(true, value);
+		}
+		[TestMethod]
+		public void TryGetBoolean_NullObjectReturnsNull()
+		{
+			JsonObject json = null;
+
+			var value = json.TryGetBoolean("boolean");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetBoolean_ValueNotFoundReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6}
+				};
+			var value = json.TryGetBoolean("boolean");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetBoolean_ValueNotBooleanReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"boolean", true}
+				};
+			var value = json.TryGetBoolean("string");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetArray_ReturnsRequested()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"array", new JsonArray()}
+				};
+
+			var value = json.TryGetArray("array");
+
+			Assert.AreEqual(new JsonArray(), value);
+		}
+		[TestMethod]
+		public void TryGetArray_NullObjectReturnsNull()
+		{
+			JsonObject json = null;
+
+			var value = json.TryGetArray("array");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetArray_ValueNotFoundReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6}
+				};
+			var value = json.TryGetArray("array");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetArray_ValueNotBooleanReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"array", new JsonArray()}
+				};
+			var value = json.TryGetArray("string");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetObject_ReturnsRequested()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"object", new JsonObject()}
+				};
+
+			var value = json.TryGetObject("object");
+
+			Assert.AreEqual(new JsonObject(), value);
+		}
+		[TestMethod]
+		public void TryGetObject_NullObjectReturnsNull()
+		{
+			JsonObject json = null;
+
+			var value = json.TryGetObject("object");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetObject_ValueNotFoundReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6}
+				};
+			var value = json.TryGetObject("object");
+
+			Assert.IsNull(value);
+		}
+		[TestMethod]
+		public void TryGetObject_ValueNotBooleanReturnsNull()
+		{
+			var json = new JsonObject
+				{
+					{"string", "test"},
+					{"number", 6},
+					{"object", new JsonObject()}
+				};
+			var value = json.TryGetObject("string");
+
+			Assert.IsNull(value);
+		}
+	}
+}

File Json.Tests/Json/Helpers/PrimitiveMapperTest.cs

-/***************************************************************************************
-
-	Copyright 2012 Greg Dennis
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		PrimitiveMapperTest.cs
-	Namespace:		Manatee.Tests.Json.Helpers
-	Class Name:		PrimitiveMapperTest
-	Purpose:		This is a test class for PrimitiveMapper and is intended
-					to contain all PrimitiveMapper Unit Tests
-
-***************************************************************************************/
-using System;
-using Manatee.Json;
-using Manatee.Json.Exceptions;
-using Manatee.Json.Helpers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Manatee.Tests.Json.Helpers
-{
-	[TestClass]
-	public class PrimitiveMapperTest
-	{
-		private readonly PrimitiveMapper _mapper = new PrimitiveMapper(new ObjectCaster());
-
-		#region MapFromJson Tests
-		[TestMethod]
-		public void MapFromJson_ParameterIsNotPrimitive_ThrowsNotPrimitiveTypeException()
-		{
-			JsonValue json = new JsonObject();
-			try
-			{
-				_mapper.MapFromJson<Uri>(json);
-				Assert.Fail("Expected NotPrimitiveTypeException");
-			}
-			catch (NotPrimitiveTypeException) { }
-			catch (Exception e)
-			{
-				Assert.Fail(string.Format("Incorrect exception thrown: {0}", e));
-			}
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsString_ReturnsCorrectString()
-		{
-			var json = new JsonValue("test");
-			var expected = "test";
-			var actual = _mapper.MapFromJson<string>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsInt_ReturnsCorrectInt()
-		{
-			var json = new JsonValue(42);
-			var expected = 42;
-			var actual = _mapper.MapFromJson<int>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsDouble_ReturnsCorrectDouble()
-		{
-			var json = new JsonValue(42.0);
-			var expected = 42.0;
-			var actual = _mapper.MapFromJson<double>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsBool_ReturnsCorrectBool()
-		{
-			var json = new JsonValue(true);
-			var expected = true;
-			var actual = _mapper.MapFromJson<bool>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsNotConvertibleToString_ValueIsString_ReturnsDefaultString()
-		{
-			var json = JsonValue.Null;
-			var expected = default(string);
-			var actual = _mapper.MapFromJson<string>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsNotConvertibleToInt_ValueIsInt_ReturnsDefaultInt()
-		{
-			var json = JsonValue.Null;
-			var expected = default(int);
-			var actual = _mapper.MapFromJson<int>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsNotConvertibleToDouble_ValueIsDouble_ReturnsDefaultDouble()
-		{
-			var json = JsonValue.Null;
-			var expected = default(double);
-			var actual = _mapper.MapFromJson<double>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapFromJson_ParameterIsNotConvertibleToBool_ValueIsBool_ReturnsDefaultBool()
-		{
-			var json = JsonValue.Null;
-			var expected = default(bool);
-			var actual = _mapper.MapFromJson<bool>(json);
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-
-		#region MapToJson Tests
-		[TestMethod]
-		public void MapToJson_MapsStringCorrectly()
-		{
-			var obj = "test";
-			var expected = new JsonValue(obj);
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsIntCorrectly()
-		{
-			var obj = 42;
-			var expected = new JsonValue(obj);
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsDoubleCorrectly()
-		{
-			var obj = 42.0;
-			var expected = new JsonValue(obj);
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsBoolCorrectly()
-		{
-			var obj = true;
-			var expected = new JsonValue(obj);
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsEnumCorrectly()
-		{
-			var obj = UriKind.Absolute;
-			var expected = new JsonValue((int)obj);
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsOtherValueTypeToDefaultValue()
-		{
-			var obj = DateTime.Today;
-			var expected = JsonValue.Null;
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		[TestMethod]
-		public void MapToJson_MapsOtherReferenceTypeToNull()
-		{
-			var obj = new UriBuilder();
-			var expected = JsonValue.Null;
-			var actual = _mapper.MapToJson(obj);
-			Assert.AreEqual(expected, actual);
-		}
-		#endregion
-	}
-}

File Json.Tests/Json/Serialization/Internal/TypeGeneratorTest.cs

+using System;
+using Manatee.Json.Serialization.Internal;
+using Manatee.Tests.Test_References;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Manatee.Tests.Json.Serialization.Internal
+{
+	[TestClass]
+	public class TypeGeneratorTest
+	{
+		[TestMethod]
+		public void TypeCreation_Success()
+		{
+			var instance = TypeGenerator.Default.Generate<IInterface>();
+
+			Assert.IsNotNull(instance);
+		}
+		[TestMethod]
+		public void PropertyReadAndWrite_Success()
+		{
+			string stringProp = "test";
+
+			var instance = TypeGenerator.Default.Generate<IInterface>();
+			instance.RequiredProp = stringProp;
+
+			Assert.AreEqual(stringProp, instance.RequiredProp);
+		}
+		[TestMethod]
+		public void MethodCall_Success()
+		{
+			var instance = TypeGenerator.Default.Generate<IInterface>();
+
+			var actual = instance.RequiredMethod<int, IConvertible>(2.0);
+
+			Assert.AreEqual(default(int), actual);
+		}
+		[TestMethod]
+		public void CacheTypes_Success()
+		{
+			var instance = TypeGenerator.Default.Generate<IInterface>();
+			var instance2 = TypeGenerator.Default.Generate<IInterface>();
+
+			Assert.AreNotSame(instance, instance2);
+			Assert.AreEqual(instance.GetType(), instance2.GetType());
+			Console.WriteLine("Caching succeeded.");
+		}
+	}
+}

File Json.Tests/Json/Serialization/JsonSerializerTest.cs

 		public void Deserialize_DateTimeJavaFormat_Successful()
 		{
 			_serializer.Options = new JsonSerializerOptions
-			{
-				DateTimeSerializationFormat = DateTimeSerializationFormat.JavaConstructor
-			};
+				{
+					DateTimeSerializationFormat = DateTimeSerializationFormat.JavaConstructor
+				};
 			JsonValue json = string.Format("/Date({0})/", DateTime.Today.Ticks/TimeSpan.TicksPerMillisecond);
 			var expected = DateTime.Today;
 			var actual = _serializer.Deserialize<DateTime>(json);
 		public void Deserialize_DateTimeMilliseconds_Successful()
 		{
 			_serializer.Options = new JsonSerializerOptions
-			{
-				DateTimeSerializationFormat = DateTimeSerializationFormat.Milliseconds
-			};
+				{
+					DateTimeSerializationFormat = DateTimeSerializationFormat.Milliseconds
+				};
 			JsonValue json = DateTime.Today.Ticks/TimeSpan.TicksPerMillisecond;
 			var expected = DateTime.Today;
 			var actual = _serializer.Deserialize<DateTime>(json);
 		public void Deserialize_Basic_Successful()
 		{
 			var json = new JsonObject
-			           	{
-			           		{"StringProp", "stringValue"},
-			           		{"IntProp", 42},
-			           		{"DoubleProp", 6},
-			           		{"BoolProp", true},
-							{"EnumProp", 2},
-							{"MapToMe", 4}
-			           	};
+				{
+					{"StringProp", "stringValue"},
+					{"IntProp", 42},
+					{"DoubleProp", 6},
+					{"BoolProp", true},
+					{"EnumProp", 2},
+					{"MapToMe", 4}
+				};
 			var expected = new ObjectWithBasicProps
-			               	{
-			               		StringProp = "stringValue",
-			               		IntProp = 42,
-			               		DoubleProp = 6.0,
-			               		BoolProp = true,
-			               		EnumProp = JsonValueType.Boolean,
-								MappedProp = 4
-							};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					DoubleProp = 6.0,
+					BoolProp = true,
+					EnumProp = JsonValueType.Boolean,
+					MappedProp = 4
+				};
 			var actual = _serializer.Deserialize<ObjectWithBasicProps>(json);
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		public void Deserialize_AbstractAndInterfacePropsWithoutMap_Successful()
 		{
-			var json = new JsonObject{
-										{"AbstractProp", new JsonObject
-															{
-																{"#Type", typeof(DerivedClass).AssemblyQualifiedName},
-																{"SomeProp", 42}
-															}},
-										{"InterfaceProp", new JsonObject
-															{
-			                     								{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
-			                     								{"RequiredProp", "test"}
-															}}
-									};
+			var json = new JsonObject
+				{
+					{
+						"AbstractProp", new JsonObject
+							{
+								{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
+								{"SomeProp", 42}
+							}
+					},
+					{
+						"InterfaceProp", new JsonObject
+							{
+								{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
+								{"RequiredProp", "test"}
+							}
+					}
+				};
 			var expected = new ObjectWithAbstractAndInterfaceProps
 			               	{
 			               		AbstractProp = new DerivedClass {SomeProp = 42},
 		[TestMethod]
 		public void Deserialize_AbstractAndInterfacePropsWithMap_Successful()
 		{
-			var json = new JsonObject{
-										{"AbstractProp", new JsonObject
-															{
-																{"#Type", typeof(DerivedClass).AssemblyQualifiedName},
-																{"SomeProp", 42}
-															}},
-										{"InterfaceProp", new JsonObject {{"RequiredProp", "test"}}}
-									};
+			var json = new JsonObject
+				{
+					{
+						"AbstractProp", new JsonObject
+							{
+								{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
+								{"SomeProp", 42}
+							}
+					},
+					{"InterfaceProp", new JsonObject {{"RequiredProp", "test"}}}
+				};
 			var expected = new ObjectWithAbstractAndInterfaceProps
-			               	{
-			               		AbstractProp = new DerivedClass {SomeProp = 42},
-			               		InterfaceProp = new ImplementationClass {RequiredProp = "test"}
-			               	};
-			JsonSerializationAbstractionMap.Map<Interface, ImplementationClass>();
+				{
+					AbstractProp = new DerivedClass {SomeProp = 42},
+					InterfaceProp = new ImplementationClass {RequiredProp = "test"}
+				};
+			JsonSerializationAbstractionMap.Map<IInterface, ImplementationClass>();
 			var actual = _serializer.Deserialize<ObjectWithAbstractAndInterfaceProps>(json);
-			JsonSerializationAbstractionMap.RemoveMap<Interface>();
+			JsonSerializationAbstractionMap.RemoveMap<IInterface>();
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		public void Deserialize_AbstractClass_Successful()
 		{
 			var json = new JsonObject
-			           	{
-			           		{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
-			           		{"SomeProp", 42},
-			           		{"NewProp", "test"}
-			           	};
+				{
+					{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
+					{"SomeProp", 42},
+					{"NewProp", "test"}
+				};
 			AbstractClass expected = new DerivedClass
-			                         	{
-			                         		SomeProp = 42,
-			                         		NewProp = "test"
-			                         	};
+				{
+					SomeProp = 42,
+					NewProp = "test"
+				};
 
 			var actual = _serializer.Deserialize<AbstractClass>(json);
 			Assert.AreEqual(expected, actual);
 		public void Deserialize_Interface_Successful()
 		{
 			JsonValue json = new JsonObject
-			                     	{
-			                     		{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
-			                     		{"RequiredProp", "test"}
-			                     	};
-			Interface expected = new ImplementationClass {RequiredProp = "test"};
+				{
+					{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
+					{"RequiredProp", "test"}
+				};
+			IInterface expected = new ImplementationClass {RequiredProp = "test"};
 
-			var actual = _serializer.Deserialize<Interface>(json);
+			var actual = _serializer.Deserialize<IInterface>(json);
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		{
 			var expected = new JsonCompatibleClass("test string", 42);
 			var json = new JsonObject
-			               	{
-			               		{"StringProp", "test string"},
-			               		{"IntProp", 42}
-			               	};
+				{
+					{"StringProp", "test string"},
+					{"IntProp", 42}
+				};
 			var actual = _serializer.Deserialize<JsonCompatibleClass>(json);
 			Assert.AreEqual(expected, actual);
 		}
 			JsonSerializationTypeRegistry.RegisterDictionaryType<string, double>();
 			var expected = new Dictionary<string, double> {{"four", 4}, {"three", 3}, {"five", 5}, {"six", 6}};
 			JsonValue json = new JsonArray
-			                     	{
-			                     		new JsonObject {{"Key", "four"}, {"Value", 4}},
-			                     		new JsonObject {{"Key", "three"}, {"Value", 3}},
-			                     		new JsonObject {{"Key", "five"}, {"Value", 5}},
-			                     		new JsonObject {{"Key", "six"}, {"Value", 6}}
-			                     	};
+				{
+					new JsonObject {{"Key", "four"}, {"Value", 4}},
+					new JsonObject {{"Key", "three"}, {"Value", 3}},
+					new JsonObject {{"Key", "five"}, {"Value", 5}},
+					new JsonObject {{"Key", "six"}, {"Value", 6}}
+				};
 			var actual = _serializer.Deserialize<Dictionary<string, double>>(json);
 			Assert.AreEqual(expected.Count, actual.Count);
 			foreach (var key in actual.Keys)
 			var doubleProp = 6.0;
 			var boolProp = true;
 			var json = new JsonObject
-			           	{
-			           		{"StaticStringProp", "staticStringValue"},
-			           		{"StaticIntProp", 42},
-			           		{"StaticDoubleProp", 6},
-			           		{"StaticBoolProp", true}
-			           	};
+				{
+					{"StaticStringProp", "staticStringValue"},
+					{"StaticIntProp", 42},
+					{"StaticDoubleProp", 6},
+					{"StaticBoolProp", true}
+				};
 			_serializer.DeserializeType<ObjectWithBasicProps>(json);
 			Assert.AreEqual(ObjectWithBasicProps.StaticStringProp, stringProp);
 			Assert.AreEqual(ObjectWithBasicProps.StaticIntProp, intProp);
 		public void Deserialize_DefaultOptions_IgnoresExtraProperties()
 		{
 			var json = new JsonObject
-			           	{
-			           		{"StringProp", "stringValue"},
-			           		{"IntProp", 42},
-							{"UnknownProp", "string"},
-			           		{"DoubleProp", 6},
-			           		{"BoolProp", true},
-							{"OtherProp", Math.PI}
-			           	};
+				{
+					{"StringProp", "stringValue"},
+					{"IntProp", 42},
+					{"UnknownProp", "string"},
+					{"DoubleProp", 6},
+					{"BoolProp", true},
+					{"OtherProp", Math.PI}
+				};
 			var expected = new ObjectWithBasicProps
-			               	{
-			               		StringProp = "stringValue",
-			               		IntProp = 42,
-			               		DoubleProp = 6.0,
-			               		BoolProp = true
-			               	};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					DoubleProp = 6.0,
+					BoolProp = true
+				};
 			var actual = _serializer.Deserialize<ObjectWithBasicProps>(json);
 			Assert.AreEqual(expected, actual);
 		}
 											InvalidPropertyKeyBehavior = InvalidPropertyKeyBehavior.ThrowException
 										};
 				var json = new JsonObject
-			           	{
-			           		{"StringProp", "stringValue"},
-			           		{"IntProp", 42},
-							{"UnknownProp", "string"},
-			           		{"DoubleProp", 6},
-			           		{"BoolProp", true},
-							{"OtherProp", Math.PI}
-			           	};
+					{
+						{"StringProp", "stringValue"},
+						{"IntProp", 42},
+						{"UnknownProp", "string"},
+						{"DoubleProp", 6},
+						{"BoolProp", true},
+						{"OtherProp", Math.PI}
+					};
 				var expected = new ObjectWithBasicProps
-				{
-					StringProp = "stringValue",
-					IntProp = 42,
-					DoubleProp = 6.0,
-					BoolProp = true
-				};
+					{
+						StringProp = "stringValue",
+						IntProp = 42,
+						DoubleProp = 6.0,
+						BoolProp = true
+					};
 				var actual = _serializer.Deserialize<ObjectWithBasicProps>(json);
 				Assert.Fail("Did not throw exception.");
 			}
 			}
 			catch (Exception e)
 			{
-				Assert.Fail(string.Format("Threw {0}.", e.GetType()));
+				Assert.Fail("Threw {0}.", e.GetType());
 			}
 			finally
 			{
 		[TestMethod]
 		public void Deserialize_CircularStructure_MaintainsReferences()
 		{
-			var json = JsonValue.Parse(@"{""LoopProperty"":{""LoopProperty"":{""#Ref"":""f3a2993b-9b0c-4296-872e-95a9210295f4""},""StringProp"":""stringValueB"",""IntProp"":6,""BoolProp"":true},""StringProp"":""stringValueA"",""IntProp"":42,""#Define"":""f3a2993b-9b0c-4296-872e-95a9210295f4""}");
+			var json = new JsonObject
+				{
+					{
+						"LoopProperty", new JsonObject
+							{
+								{"LoopProperty", new JsonObject {{"#Ref", "f3a2993b-9b0c-4296-872e-95a9210295f4"}}},
+								{"StringProp", "stringValueB"},
+								{"IntProp", 6},
+								{"BoolProp", true}
+							}
+					},
+					{"StringProp", "stringValueA"},
+					{"IntProp", 42},
+					{"#Def", "f3a2993b-9b0c-4296-872e-95a9210295f4"}
+				};
 			var expected = new ObjectWithExtendedProps
-			{
-				StringProp = "stringValueA",
-				IntProp = 42
-			};
+				{
+					StringProp = "stringValueA",
+					IntProp = 42
+				};
 			var obj2 = new ObjectWithExtendedProps
-			{
-				StringProp = "stringValueB",
-				IntProp = 6,
-				BoolProp = true,
-				LoopProperty = expected
-			};
+				{
+					StringProp = "stringValueB",
+					IntProp = 6,
+					BoolProp = true,
+					LoopProperty = expected
+				};
 			expected.LoopProperty = obj2;
 
 			var actual = _serializer.Deserialize<ObjectWithExtendedProps>(json);
 			Assert.AreEqual(expected.LoopProperty.StringProp, actual.LoopProperty.StringProp);
 			Assert.IsNotNull(actual.LoopProperty.LoopProperty);
 			Assert.AreSame(actual, actual.LoopProperty.LoopProperty);
+			Assert.AreEqual(0, _serializer.SerializationMap.Count);
+		}
+		[TestMethod]
+		public void Deserialize_UnimplementedInterface_ReturnsRunTimeImplementation()
+		{
+			var json = new JsonObject {{"RequiredProp", "test"}};
+			IInterface expected = new ImplementationClass {RequiredProp = "test"};
+
+			var actual = _serializer.Deserialize<IInterface>(json);
+
+			Assert.IsNotNull(actual);
+			Assert.AreNotEqual(expected.GetType(), actual.GetType());
+			Assert.AreEqual(expected.RequiredProp, actual.RequiredProp);
 		}
 		#endregion
 
 		public void Serialize_Basic_Successful()
 		{
 			var obj = new ObjectWithBasicProps
-						{
-							StringProp = "stringValue",
-							IntProp = 42,
-							DoubleProp = 6.0,
-							BoolProp = true,
-							EnumProp = JsonValueType.Boolean,
-							MappedProp = 4
-						};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					DoubleProp = 6.0,
+					BoolProp = true,
+					EnumProp = JsonValueType.Boolean,
+					MappedProp = 4
+				};
 			JsonValue expected = new JsonObject
-									{
-										{"StringProp", "stringValue"},
-										{"IntProp", 42},
-										{"DoubleProp", 6},
-										{"BoolProp", true},
-										{"EnumProp", 2},
-										{"MapToMe", 4}
-									};
+				{
+					{"StringProp", "stringValue"},
+					{"IntProp", 42},
+					{"DoubleProp", 6},
+					{"BoolProp", true},
+					{"EnumProp", 2},
+					{"MapToMe", 4}
+				};
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		}
 			          		InterfaceProp = new ImplementationClass {RequiredProp = "test comparable"}
 			          	};
 			JsonValue expected = new JsonObject
-									{
-										{"AbstractProp", new JsonObject
-															{
-																{"#Type", typeof(DerivedClass).AssemblyQualifiedName},
-																{"SomeProp", 42}}
-															},
-										{"InterfaceProp", new JsonObject
-															{
-																{"#Type", typeof(ImplementationClass).AssemblyQualifiedName},
-																{"RequiredProp", "test comparable"}}
-															}
-									};
+				{
+					{
+						"AbstractProp", new JsonObject
+							{
+								{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
+								{"SomeProp", 42}
+							}
+					},
+					{
+						"InterfaceProp", new JsonObject
+							{
+								{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
+								{"RequiredProp", "test comparable"}
+							}
+					}
+				};
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		}
 		public void Serialize_AbstractClass_Successful()
 		{
 			AbstractClass obj = new DerivedClass
-			                    	{
-			                    		SomeProp = 42,
-										NewProp = "test"
-			                    	};
+				{
+					SomeProp = 42,
+					NewProp = "test"
+				};
 			JsonValue expected = new JsonObject
-			                     	{
-			                     		{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
-			                     		{"SomeProp", 42},
-			                     		{"NewProp", "test"}
-			                     	};
+				{
+					{"#Type", typeof (DerivedClass).AssemblyQualifiedName},
+					{"SomeProp", 42},
+					{"NewProp", "test"}
+				};
 
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		[TestMethod]
 		public void Serialize_Interface_Successful()
 		{
-			Interface obj = new ImplementationClass {RequiredProp = "test"};
+			IInterface obj = new ImplementationClass {RequiredProp = "test"};
 			JsonValue expected = new JsonObject
-			                     	{
-			                     		{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
-			                     		{"RequiredProp", "test"}
-			                     	};
+				{
+					{"#Type", typeof (ImplementationClass).AssemblyQualifiedName},
+					{"RequiredProp", "test"}
+				};
 
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		{
 			var obj = new JsonCompatibleClass("test string", 42);
 			var expected = new JsonObject
-			               	{
-			               		{"StringProp", "test string"},
-			               		{"IntProp", 42}
-			               	};
+				{
+					{"StringProp", "test string"},
+					{"IntProp", 42}
+				};
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		}
 			JsonSerializationTypeRegistry.RegisterDictionaryType<string, double>();
 			var dict = new Dictionary<string, double> {{"four", 4}, {"three", 3}, {"five", 5}, {"six", 6}};
 			JsonValue expected = new JsonArray
-			                     	{
-			                     		new JsonObject {{"Key", "four"},{"Value", 4}},
-			                     		new JsonObject {{"Key", "three"}, {"Value", 3}},
-			                     		new JsonObject {{"Key", "five"}, {"Value", 5}},
-			                     		new JsonObject {{"Key", "six"}, {"Value", 6}}
-			                     	};
+				{
+					new JsonObject {{"Key", "four"}, {"Value", 4}},
+					new JsonObject {{"Key", "three"}, {"Value", 3}},
+					new JsonObject {{"Key", "five"}, {"Value", 5}},
+					new JsonObject {{"Key", "six"}, {"Value", 6}}
+				};
 			var actual = _serializer.Serialize(dict);
 			Assert.AreEqual(expected, actual);
 		}
 			ObjectWithBasicProps.StaticDoubleProp = 6.0;
 			ObjectWithBasicProps.StaticBoolProp = true;
 			JsonValue expected = new JsonObject
-									{
-										{"StaticStringProp", "staticStringValue"},
-										{"StaticIntProp", 42},
-										{"StaticDoubleProp", 6},
-										{"StaticBoolProp", true}
-									};
+				{
+					{"StaticStringProp", "staticStringValue"},
+					{"StaticIntProp", 42},
+					{"StaticDoubleProp", 6},
+					{"StaticBoolProp", true}
+				};
 			var actual = _serializer.SerializeType<ObjectWithBasicProps>();
 			Assert.AreEqual(expected, actual);
 		}
 				BoolProp = true
 			};
 			JsonValue expected = new JsonObject
-									{
-										{"StringProp", "stringValue"},
-										{"IntProp", 42},
-										{"BoolProp", true}
-									};
+				{
+					{"StringProp", "stringValue"},
+					{"IntProp", 42},
+					{"BoolProp", true}
+				};
 			var actual = _serializer.Serialize(obj);
 			Assert.AreEqual(expected, actual);
 		}
 			                      	};
 			// DoubleProp remains default
 			var obj = new ObjectWithBasicProps
-			          	{
-			          		StringProp = "stringValue",
-			          		IntProp = 42,
-			          		BoolProp = true
-			          	};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					BoolProp = true
+				};
 			JsonValue expected = new JsonObject
-									{
-										{"StringProp", "stringValue"},
-										{"IntProp", 42},
-										{"DoubleProp", 0},
-										{"BoolProp", true},
-										{"EnumProp", 0},
-										{"MapToMe", 0}
-									};
+				{
+					{"StringProp", "stringValue"},
+					{"IntProp", 42},
+					{"DoubleProp", 0},
+					{"BoolProp", true},
+					{"EnumProp", 0},
+					{"MapToMe", 0}
+				};
 			var actual = _serializer.Serialize(obj);
 			_serializer.Options = null;
 			Assert.AreEqual(expected, actual);
 		public void Serialize_CircularStructure_SerializesWithReference()
 		{
 			var obj = new ObjectWithExtendedProps
-			          	{
-			          		StringProp = "stringValue",
-			          		IntProp = 42,
-			          		BoolProp = true
-			          	};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					BoolProp = true
+				};
 			var obj2 = new ObjectWithExtendedProps
-			{
-				StringProp = "stringValue",
-				IntProp = 42,
-				BoolProp = true,
-				LoopProperty = obj
-			};
+				{
+					StringProp = "stringValue",
+					IntProp = 42,
+					BoolProp = true,
+					LoopProperty = obj
+				};
 			obj.LoopProperty = obj2;
 
 			var actual = _serializer.Serialize(obj);
 
 			Assert.IsNotNull(actual);
 			Assert.AreEqual(JsonValueType.Object, actual.Type);
-			Assert.IsTrue(actual.Object.ContainsKey("#Define"));
+			Assert.IsTrue(actual.Object.ContainsKey("#Def"));
 			Assert.IsTrue(actual.Object.ContainsKey("LoopProperty"));
 			Assert.AreEqual(JsonValueType.Object, actual.Object["LoopProperty"].Type);
 			Assert.IsTrue(actual.Object["LoopProperty"].Object.ContainsKey("LoopProperty"));
 			Assert.AreEqual(JsonValueType.Object, actual.Object["LoopProperty"].Object["LoopProperty"].Type);
 			Assert.IsTrue(actual.Object["LoopProperty"].Object["LoopProperty"].Object.ContainsKey("#Ref"));
-			Assert.AreEqual(actual.Object["#Define"], actual.Object["LoopProperty"].Object["LoopProperty"].Object["#Ref"]);
+			Assert.AreEqual(actual.Object["#Def"], actual.Object["LoopProperty"].Object["LoopProperty"].Object["#Ref"]);
+			Assert.AreEqual(0, _serializer.SerializationMap.Count);
 		}
 		#endregion
 	}

File Json.Tests/Manatee.Tests.csproj

     </CodeAnalysisDependentAssemblyPaths>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Json\Extensions\JsonExtensionsTest.cs" />
+    <Compile Include="Json\Extensions\JsonArrayExtensionsTest.cs" />
+    <Compile Include="Json\Extensions\JsonObjectExtensionsTest.cs" />
     <Compile Include="Json\Extensions\XmlExtensionsTest.cs" />
     <Compile Include="Json\JsonObjectTest.cs" />
     <Compile Include="Json\JsonArrayTest.cs" />
     <Compile Include="Json\JsonValueTest.cs" />
     <Compile Include="Json\Extensions\LinqExtensionsTest.cs" />
+    <Compile Include="Json\Serialization\Internal\TypeGeneratorTest.cs" />
     <Compile Include="Json\Serialization\JsonSerializerTest.cs" />
-    <Compile Include="Json\Helpers\PrimitiveMapperTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Test References\AbstractClass.cs" />
     <Compile Include="Test References\DerivedClass.cs" />
     <Compile Include="Test References\ImplementationClass.cs" />
-    <Compile Include="Test References\Interface.cs" />
+    <Compile Include="Test References\IInterface.cs" />
     <Compile Include="Test References\JsonCompatibleClass.cs" />
     <Compile Include="Test References\ObjectWithAbstractAndInterfaceProps.cs" />
     <Compile Include="Test References\ObjectWithBasicProps.cs" />

File Json.Tests/Test References/IInterface.cs

+using System;
+
+namespace Manatee.Tests.Test_References
+{
+	public interface IInterface : IComparable
+	{
+		string this[int a] { get; set; }
+		string RequiredProp { get; set; }
+		T RequiredMethod<T, U>(U str) where T : U;
+	}
+}

File Json.Tests/Test References/ImplementationClass.cs

 
 namespace Manatee.Tests.Test_References
 {
-	public class ImplementationClass : Interface
+	public class ImplementationClass : IInterface
 	{
+		public string this[int a]
+		{
+			get { throw new NotImplementedException(); }
+			set { throw new NotImplementedException(); }
+		}
 		public string RequiredProp { get; set; }
 
+		public T RequiredMethod<T, U>(U str) where T : U
+		{
+			return default(T);
+		}
+
 		public override bool Equals(object obj)
 		{
 			if (!(obj is ImplementationClass)) return false;
 		{
 			return (RequiredProp != null ? RequiredProp.GetHashCode() : 0);
 		}
+		public int CompareTo(object obj)
+		{
+			throw new NotImplementedException();
+		}
 	}
 }

File Json.Tests/Test References/Interface.cs

-namespace Manatee.Tests.Test_References
-{
-	public interface Interface
-	{
-		string RequiredProp { get; set; }
-	}
-}

File Json.Tests/Test References/ObjectWithAbstractAndInterfaceProps.cs

 {
 	public class ObjectWithAbstractAndInterfaceProps
 	{
-		public Interface InterfaceProp { get; set; }
+		public IInterface InterfaceProp { get; set; }
 		public AbstractClass AbstractProp { get; set; }
 
 		public override bool Equals(object obj)
 
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manatee.Json", "Json\Manatee.Json.csproj", "{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Manatee.Tests", "Json.Tests\Manatee.Tests.csproj", "{E74B7538-5E17-43C7-925B-33784945312E}"
 	EndGlobalSection
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
-		Publish|Any CPU = Publish|Any CPU
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
-		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Publish|Any CPU.Build.0 = Publish|Any CPU
 		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6ADF0BCF-4E46-4605-A784-51EA6DAC81C7}.Release|Any CPU.Build.0 = Release|Any CPU
 		{E74B7538-5E17-43C7-925B-33784945312E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{E74B7538-5E17-43C7-925B-33784945312E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{E74B7538-5E17-43C7-925B-33784945312E}.Publish|Any CPU.ActiveCfg = Release|Any CPU
 		{E74B7538-5E17-43C7-925B-33784945312E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution

File Json.v11.suo

Binary file added.

File Json/Enumerations/EnumSerializationFormat.cs

+/***************************************************************************************
+
+	Copyright 2012 Greg Dennis
+
+	   Licensed under the Apache License, Version 2.0 (the "License");
+	   you may not use this file except in compliance with the License.
+	   You may obtain a copy of the License at
+
+		 http://www.apache.org/licenses/LICENSE-2.0
+
+	   Unless required by applicable law or agreed to in writing, software
+	   distributed under the License is distributed on an "AS IS" BASIS,
+	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	   See the License for the specific language governing permissions and
+	   limitations under the License.
+ 
+	File Name:		EnumSerializationFormat.cs
+	Namespace:		Manatee.Json.Enumerations
+	Class Name:		EnumSerializationFormat
+	Purpose:		Enumerates serialization formats for enumerations.
+
+***************************************************************************************/
+
+namespace Manatee.Json.Enumerations
+{
+	/// <summary>
+	/// Enumerates serialization formats for enumerations.
+	/// </summary>
+	public enum EnumSerializationFormat
+	{
+		/// <summary>
+		/// Instructs the serializer to convert enumeration values to their numeric
+		/// counterparts.
+		/// </summary>
+		AsInteger,
+		/// <summary>
+		/// Instructs the serializer to convert enumeration values to their string
+		/// counterparts.
+		/// </summary>
+		/// <remarks>
+		/// This option will use the Description attribute if it is present.  If the
+		/// enumeration is marked with the flags attribute, the string representation
+		/// will consist of a comma-delimited list of names.  Whenever a value is
+		/// passed which does not have a named counterpart, the numeric value will
+		/// be used.
+		/// </remarks>
+		AsName
+	}
+}

File Json/Extensions/JsonArrayExtensions.cs

+/***************************************************************************************
+
+	Copyright 2013 Little Crab Solutions
+
+	   Licensed under the Apache License, Version 2.0 (the "License");
+	   you may not use this file except in compliance with the License.
+	   You may obtain a copy of the License at
+
+		 http://www.apache.org/licenses/LICENSE-2.0
+
+	   Unless required by applicable law or agreed to in writing, software
+	   distributed under the License is distributed on an "AS IS" BASIS,
+	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	   See the License for the specific language governing permissions and
+	   limitations under the License.
+ 
+	File Name:		JsonArrayExtensions.cs
+	Namespace:		Manatee.Json
+	Class Name:		JsonArrayExtensions
+	Purpose:		Provides extension methods for JsonArrays.
+
+***************************************************************************************/
+using System.Linq;
+using Manatee.Json.Enumerations;
+
+namespace Manatee.Json.Extensions
+{
+	/// <summary>
+	/// Provides extension methods for JsonArrays.
+	/// </summary>
+	public static class JsonArrayExtensions
+	{
+		/// <summary>
+		/// Returns a JsonArray containing only the JsonValues of a specified type from a given JsonArray.
+		/// </summary>
+		/// <param name="arr">The array to search</param>
+		/// <param name="type">The type of value to return</param>
+		/// <returns>A JsonArray containing only the JsonValues of a specified type</returns>
+		public static JsonArray OfType(this JsonArray arr, JsonValueType type)
+		{
+			if (arr == null) return null;
+			var retVal = new JsonArray();
+			retVal.AddRange(arr.Where(j => j.Type == type));
+			return retVal;
+		}
+	}
+}

File Json/Extensions/JsonExtensions.cs

-/***************************************************************************************
-
-	Copyright 2013 Little Crab Solutions
-
-	   Licensed under the Apache License, Version 2.0 (the "License");
-	   you may not use this file except in compliance with the License.
-	   You may obtain a copy of the License at
-
-		 http://www.apache.org/licenses/LICENSE-2.0
-
-	   Unless required by applicable law or agreed to in writing, software
-	   distributed under the License is distributed on an "AS IS" BASIS,
-	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	   See the License for the specific language governing permissions and
-	   limitations under the License.
- 
-	File Name:		JsonExtensions.cs
-	Namespace:		Manatee.Json
-	Class Name:		JsonExtensions
-	Purpose:		Provides extension methods for JsonObjects.
-
-***************************************************************************************/
-using Manatee.Json.Enumerations;
-
-namespace Manatee.Json.Extensions
-{
-	/// <summary>
-	/// Provides extension methods for JsonValues.
-	/// </summary>
-	public static class JsonExtensions
-	{
-		/// <summary>
-		/// Returns a string or null if the key is not found or is not a string.
-		/// </summary>
-		/// <param name="obj">The object to search</param>
-		/// <param name="key">The key</param>
-		/// <returns>A string or null if the key is not found or is not a string</returns>
-		public static string TryGetString(this JsonObject obj, string key)
-		{
-			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.String) ? obj[key].String : null;
-		}
-		/// <summary>
-		/// Returns a double or null if the key is not found or is not a string.
-		/// </summary>
-		/// <param name="obj">The object to search</param>
-		/// <param name="key">The key</param>
-		/// <returns>A double or null if the key is not found or is not a string</returns>
-		public static double? TryGetNumber(this JsonObject obj, string key)
-		{
-			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Number) ? obj[key].Number : (double?)null;
-		}
-		/// <summary>
-		/// Returns a bool or null if the key is not found or is not a string.
-		/// </summary>
-		/// <param name="obj">The object to search</param>
-		/// <param name="key">The key</param>
-		/// <returns>A bool or null if the key is not found or is not a string</returns>
-		public static bool? TryGetBoolean(this JsonObject obj, string key)
-		{
-			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Boolean) ? obj[key].Boolean : (bool?)null;
-		}
-		/// <summary>
-		/// Returns a JsonArray or null if the key is not found or is not a string.
-		/// </summary>
-		/// <param name="obj">The object to search</param>
-		/// <param name="key">The key</param>
-		/// <returns>A JsonArray or null if the key is not found or is not a string</returns>
-		public static JsonArray TryGetArray(this JsonObject obj, string key)
-		{
-			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Array) ? obj[key].Array : null;
-		}
-		/// <summary>
-		/// Returns a JsonObject or null if the key is not found or is not a string.
-		/// </summary>
-		/// <param name="obj">The object to search</param>
-		/// <param name="key">The key</param>
-		/// <returns>A JsonObject or null if the key is not found or is not a string</returns>
-		public static JsonObject TryGetObject(this JsonObject obj, string key)
-		{
-			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Object) ? obj[key].Object : null;
-		}
-	}
-}

File Json/Extensions/JsonObjectExtensions.cs

+/***************************************************************************************
+
+	Copyright 2013 Little Crab Solutions
+
+	   Licensed under the Apache License, Version 2.0 (the "License");
+	   you may not use this file except in compliance with the License.
+	   You may obtain a copy of the License at
+
+		 http://www.apache.org/licenses/LICENSE-2.0
+
+	   Unless required by applicable law or agreed to in writing, software
+	   distributed under the License is distributed on an "AS IS" BASIS,
+	   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	   See the License for the specific language governing permissions and
+	   limitations under the License.
+ 
+	File Name:		JsonObjectExtensions.cs
+	Namespace:		Manatee.Json
+	Class Name:		JsonObjectExtensions
+	Purpose:		Provides extension methods for JsonObjects.
+
+***************************************************************************************/
+
+using Manatee.Json.Enumerations;
+
+namespace Manatee.Json.Extensions
+{
+	/// <summary>
+	/// Provides extension methods for JsonValues.
+	/// </summary>
+	public static class JsonObjectExtensions
+	{
+		/// <summary>
+		/// Returns a string or null if the key is not found or is not a string.
+		/// </summary>
+		/// <param name="obj">The object to search</param>
+		/// <param name="key">The key</param>
+		/// <returns>A string or null if the key is not found or is not a string</returns>
+		public static string TryGetString(this JsonObject obj, string key)
+		{
+			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.String) ? obj[key].String : null;
+		}
+		/// <summary>
+		/// Returns a double or null if the key is not found or is not a double.
+		/// </summary>
+		/// <param name="obj">The object to search</param>
+		/// <param name="key">The key</param>
+		/// <returns>A double or null if the key is not found or is not a string</returns>
+		public static double? TryGetNumber(this JsonObject obj, string key)
+		{
+			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Number) ? obj[key].Number : (double?)null;
+		}
+		/// <summary>
+		/// Returns a bool or null if the key is not found or is not a bool.
+		/// </summary>
+		/// <param name="obj">The object to search</param>
+		/// <param name="key">The key</param>
+		/// <returns>A bool or null if the key is not found or is not a string</returns>
+		public static bool? TryGetBoolean(this JsonObject obj, string key)
+		{
+			return (obj == null) ? null : obj.ContainsKey(key) && (obj[key].Type == JsonValueType.Boolean) ? obj[key].Boolean : (bool?)null;
+		}
+		/// <summary>
+		/// Returns a JsonArray or null if the key is not found or is not a JsonArray.
+		/// </summary>
+		/// <param name="obj">The object to search</param>
+		/// <param name="key">The key</param>
+		/// <returns>A JsonArray or null if the key is not found or is not a string</returns>
+		public static JsonArray TryGetArray(this JsonObject obj, string key)
+		{