Commits

Anonymous committed 9c8f54f

Added architecture to support schema.
Incorporated schema into serializer.

  • Participants
  • Parent commits 40c47d6

Comments (0)

Files changed (61)

 NuGet/
 TestResults/
 packages/
+Manatee.Json.Tests/bin/
+Manatee.Json.Tests/obj/
+Manatee.Json/bin/
+Manatee.Json/obj/

File Manatee.Json.Tests/Test References/ImplementationClass.cs

 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 
 namespace Manatee.Tests.Test_References
 {

File Manatee.Json.Tests/bin/Debug/Manatee.Json.Tests.dll

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.Json.Tests.pdb

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.Json.dll

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.Json.pdb

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.StateMachine.dll

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.StateMachine.pdb

Binary file removed.

File Manatee.Json.Tests/bin/Debug/Manatee.StateMachine.xml

-<?xml version="1.0"?>
-<doc>
-    <assembly>
-        <name>Manatee.StateMachine</name>
-    </assembly>
-    <members>
-        <member name="T:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2">
-            <summary>
-            Thrown when no action as been defined for the the given input in the current state.
-            </summary>
-            <typeparam name="TState">The object type of the state.</typeparam>
-            <typeparam name="TInput">The object type of the input.</typeparam>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.#ctor">
-            <summary>
-            Creates a new instance of this exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.#ctor(`0,`1)">
-            <summary>
-            Creates a new instance of this exception with the default message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.#ctor(System.String)">
-            <summary>
-            Creates a new instance of this exception with a given message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.#ctor(System.String,System.Exception)">
-            <summary>
-            Creates a new instance of this exception with the a given message and inner exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
-            <summary>
-            Creates a new instance of this exception with serialization and context information.
-            </summary>
-            <param name="info">The serialization information.</param>
-            <param name="context">The context information.</param>
-        </member>
-        <member name="P:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.State">
-            <summary>
-            The state of the state machine.
-            </summary>
-        </member>
-        <member name="P:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2.Input">
-            <summary>
-            The input for the state.
-            </summary>
-        </member>
-        <member name="T:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2">
-            <summary>
-            Thrown when the current state is not set up to process the given input.
-            </summary>
-            <typeparam name="TState">The object type of the state.</typeparam>
-            <typeparam name="TInput">The object type of the input.</typeparam>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.#ctor">
-            <summary>
-            Creates a new instance of this exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.#ctor(`0,`1)">
-            <summary>
-            Creates a new instance of this exception with the default message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.#ctor(System.String)">
-            <summary>
-            Creates a new instance of this exception with a given message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.#ctor(System.String,System.Exception)">
-            <summary>
-            Creates a new instance of this exception with the a given message and inner exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
-            <summary>
-            Creates a new instance of this exception with serialization and context information.
-            </summary>
-            <param name="info">The serialization information.</param>
-            <param name="context">The context information.</param>
-        </member>
-        <member name="P:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.State">
-            <summary>
-            The state of the state machine.
-            </summary>
-        </member>
-        <member name="P:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2.Input">
-            <summary>
-            The input that the state does not recognize.
-            </summary>
-        </member>
-        <member name="T:Manatee.StateMachine.Exceptions.StateNotValidException`1">
-            <summary>
-            Thrown when the specified state is not set up in the state machine.
-            </summary>
-            <typeparam name="TState">The object type of the state.</typeparam>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.StateNotValidException`1.#ctor">
-            <summary>
-            Creates a new instance of this exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.StateNotValidException`1.#ctor(`0)">
-            <summary>
-            Creates a new instance of this exception with the default message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.StateNotValidException`1.#ctor(System.String)">
-            <summary>
-            Creates a new instance of this exception with a given message.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.StateNotValidException`1.#ctor(System.String,System.Exception)">
-            <summary>
-            Creates a new instance of this exception with the a given message and inner exception.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.Exceptions.StateNotValidException`1.#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
-            <summary>
-            Creates a new instance of this exception with serialization and context information.
-            </summary>
-            <param name="info">The serialization information.</param>
-            <param name="context">The context information.</param>
-        </member>
-        <member name="P:Manatee.StateMachine.Exceptions.StateNotValidException`1.State">
-            <summary>
-            The state that the state machine does not recognize.
-            </summary>
-        </member>
-        <member name="T:Manatee.StateMachine.InputStream`1">
-            <summary>
-            Represents a stream of input parameters for a StateMachine object.  Functions as a queue,
-            but can be reset to the beginning of the collection.
-            </summary>
-            <typeparam name="T">
-            The object type used for the inputs in the StateMachine.
-            </typeparam>
-        </member>
-        <member name="M:Manatee.StateMachine.InputStream`1.#ctor">
-            <summary>
-            A default constructor.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.InputStream`1.Reset">
-            <summary>
-            Resets the enumerator index to the start.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.InputStream`1.Next">
-            <summary>
-            Retrieves the next input object.
-            </summary>
-            <returns>
-            The next input object.
-            </returns>
-        </member>
-        <member name="P:Manatee.StateMachine.InputStream`1.IsAtEnd">
-            <summary>
-             Gets whether the current index is at the end of the stream.
-            </summary>
-        </member>
-        <member name="T:Manatee.StateMachine.StateMachine`2">
-            <summary>
-            Represents an extensible generic state machine.
-            </summary>
-            <typeparam name="TState">The object type to be used for states.</typeparam>
-            <typeparam name="TInput">The object type to be used for inputs.</typeparam>
-        </member>
-        <member name="M:Manatee.StateMachine.StateMachine`2.#ctor">
-            <summary>
-            Creates a new StateMachine object.
-            </summary>
-        </member>
-        <member name="M:Manatee.StateMachine.StateMachine`2.Run(System.Object,`0,Manatee.StateMachine.InputStream{`1})">
-            <summary>
-            Runs the state machine.
-            </summary>
-            <param name="owner">The object which created the StateMachine.</param>
-            <param name="startState">The state from which to start.</param>
-            <param name="inputStream">The input stream.</param>
-            <exception cref="T:Manatee.StateMachine.Exceptions.ActionNotDefinedForStateAndInputException`2">
-            Thrown when the input stream contains an input that the current state does
-            not recognize.
-            </exception>
-            <exception cref="T:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2">
-            Thrown when attempting to get a value for an input that the given state does
-            not recognize.
-            </exception>
-            <exception cref="T:Manatee.StateMachine.Exceptions.StateNotValidException`1">
-            Thrown when attempting to get a value for a state that the state machine
-            does not recognize.
-            </exception>
-        </member>
-        <member name="M:Manatee.StateMachine.StateMachine`2.UnregisterOwner(System.Object)">
-            <summary>
-            Disassociates an object from this StateMachine, allowing it to remove
-            all associated states.
-            </summary>
-            <param name="owner"></param>
-        </member>
-        <member name="P:Manatee.StateMachine.StateMachine`2.States">
-            <summary>
-            Gets the list of states.
-            </summary>
-        </member>
-        <member name="P:Manatee.StateMachine.StateMachine`2.Inputs">
-            <summary>
-            Gets the list of all Inputs for all states.
-            </summary>
-        </member>
-        <member name="P:Manatee.StateMachine.StateMachine`2.Actions">
-            <summary>
-            Gets the list of all actions for all state-input combinations.
-            </summary>
-        </member>
-        <member name="P:Manatee.StateMachine.StateMachine`2.UpdateFunction">
-            <summary>
-            Gets and sets a custom update function.
-            </summary>
-            <remarks>
-            The update function is called before each input is retrieved from
-            the input stream.  It is typically used to update the input stream,
-            but can also include any code that needs to be executed for each 
-            state-input evaluation.
-            </remarks>
-        </member>
-        <member name="P:Manatee.StateMachine.StateMachine`2.Item(`0,`1)">
-            <summary>
-            Provides an interface for getting and setting actions for state-input
-            combinations.
-            </summary>
-            <param name="state">The state for which to get/set the action.</param>
-            <param name="input">The input for which to get/set the action.</param>
-            <returns>
-            The action for the given state-input combination.  Throws an exception if
-            not set.
-            </returns>
-            <remarks>
-            The setter automatically adds the state and input to the States and
-            Inputs lists.
-            </remarks>
-            <exception cref="T:Manatee.StateMachine.Exceptions.InputNotValidForStateException`2">
-            Thrown when attempting to get a value for an input that the given state does
-            not recognize.
-            </exception>
-            <exception cref="T:Manatee.StateMachine.Exceptions.StateNotValidException`1">
-            Thrown when attempting to get a value for a state that the state machine
-            does not recognize.
-            </exception>
-        </member>
-        <member name="T:Manatee.StateMachine.StateMachine`2.StateMachineAction">
-            <summary>
-            Provides a method template for a state-input action.
-            </summary>
-            <param name="owner">The object which created the StateMachine.</param>
-            <param name="input">The input that triggered the function call.</param>
-            <returns>
-            The next state for this StateMachine object.
-            </returns>
-        </member>
-        <member name="T:Manatee.StateMachine.StateMachine`2.UpdateAction">
-            <summary>
-            Provides a method template for an action to be called before each iteration
-            of the state machine.
-            </summary>
-            <param name="owner">The object which created the StateMachine.</param>
-        </member>
-    </members>
-</doc>

File Manatee.Json.Tests/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Binary file removed.

File Manatee.Json.Tests/obj/Debug/Manatee.Json.Tests.dll

Binary file removed.

File Manatee.Json.Tests/obj/Debug/Manatee.Json.Tests.pdb

Binary file removed.

File Manatee.Json.Tests/obj/Debug/Manatee.Tests.csproj.FileListAbsolute.txt

-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.Json.Tests.dll
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.Json.Tests.pdb
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.Json.dll
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.StateMachine.dll
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.Json.pdb
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.StateMachine.pdb
-E:\Projects\Manatee.Json\Manatee.Json.Tests\bin\Debug\Manatee.StateMachine.xml
-E:\Projects\Manatee.Json\Manatee.Json.Tests\obj\Debug\Manatee.Tests.csprojResolveAssemblyReference.cache
-E:\Projects\Manatee.Json\Manatee.Json.Tests\obj\Debug\Manatee.Json.Tests.dll
-E:\Projects\Manatee.Json\Manatee.Json.Tests\obj\Debug\Manatee.Json.Tests.pdb

File Manatee.Json.Tests/obj/Debug/Manatee.Tests.csprojResolveAssemblyReference.cache

Binary file removed.

File Manatee.Json.Tests/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache

Binary file removed.

File Manatee.Json.Tests/obj/Release/build.force

Empty file removed.

File Manatee.Json.sln.DotSettings.user

+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+	<s:Boolean x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=0FEFC915D2974C02A962C65A360B75ED/@KeyIndexDefined">True</s:Boolean>
+	<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=0FEFC915D2974C02A962C65A360B75ED/Name/@EntryValue">Test1</s:String>
+	<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=0FEFC915D2974C02A962C65A360B75ED/XmlSerializedElements/@EntryValue">&lt;Session&gt;&lt;Elements&gt;&lt;UnitTestElement Provider="MSTest" Id="MsTest:Manatee.Json.Tests.DevTest" type="MsTestTestClassElement" TypeName="Manatee.Json.Tests.DevTest" Project="E74B7538-5E17-43C7-925B-33784945312E" /&gt;&lt;UnitTestElement Provider="MSTest" Id="MsTest:Manatee.Json.Tests.DevTest.Test1" ParentId="MsTest:Manatee.Json.Tests.DevTest" type="MsTestTestMethodElement" MethodName="Test1" TypeName="Manatee.Json.Tests.DevTest" Project="E74B7538-5E17-43C7-925B-33784945312E" /&gt;&lt;/Elements&gt;&lt;/Session&gt;</s:String></wpf:ResourceDictionary>

File Manatee.Json.v11.suo

Binary file modified.

File Manatee.Json/Extensions/LinqExtensions.cs

 		/// </summary>
 		/// <param name="list">A collection of equivalent JsonValues</param>
 		/// <returns>A JsonArray containing the equivalent JsonValues</returns>
-		public static JsonValue ToJson(this IEnumerable<IJsonCompatible> list)
+		public static JsonValue ToJson<T>(this IEnumerable<T> list)
+			where T : IJsonCompatible
 		{
 			if (list == null) return JsonValue.Null;
 			var json = new JsonArray();
 			return json;
 		}
 		/// <summary>
+		/// Converts an IEnumerable&lt;KeyValuePair&lt;string, JsonValue&gt;&gt; returned from a
+		/// LINQ query back into a JsonObject.
+		/// </summary>
+		/// <param name="results">An IEnumerable&lt;KeyValuePair&lt;string, JsonValue&gt;&gt;</param>
+		/// <returns>An equivalent JsonObject</returns>
+		public static JsonObject ToJson<T>(this IEnumerable<KeyValuePair<string, T>> results)
+			where T : IJsonCompatible
+		{
+			var json = new JsonObject();
+			foreach (var keyValuePair in results)
+			{
+				json.Add(keyValuePair.Key, keyValuePair.Value == null ? JsonValue.Null : keyValuePair.Value.ToJson());
+			}
+			return json;
+		}
+		/// <summary>
 		/// Deserializes a collection of JsonValues to an IEnumerable of the objects.
 		/// </summary>
 		/// <typeparam name="T">The type of object contained in the collection</typeparam>

File Manatee.Json/Manatee.Json.csproj

     <Compile Include="Exceptions\JsonTypeMapException.cs" />
     <Compile Include="Extensions\JsonArrayExtensions.cs" />
     <Compile Include="Helpers\ISerializerCache.cs" />
+    <Compile Include="Schema\AllOfSchema.cs" />
+    <Compile Include="Schema\AnyOfSchema.cs" />
+    <Compile Include="Schema\ArraySchema.cs" />
+    <Compile Include="Schema\BooleanSchema.cs" />
+    <Compile Include="Schema\EnumSchema.cs" />
+    <Compile Include="Schema\IJsonSchema.cs" />
+    <Compile Include="Schema\IntegerSchema.cs" />
+    <Compile Include="Schema\JsonSchema.cs" />
+    <Compile Include="Schema\NotSchema.cs" />
+    <Compile Include="Schema\NullSchema.cs" />
+    <Compile Include="Schema\NumberSchema.cs" />
+    <Compile Include="Schema\ObjectSchema.cs" />
+    <Compile Include="Schema\OneOfSchema.cs" />
+    <Compile Include="Schema\JsonSchemaFactory.cs" />
+    <Compile Include="Schema\JsonSchemaPropertyDefinition.cs" />
+    <Compile Include="Schema\JsonSchemaPropertyDefinitionCollection.cs" />
+    <Compile Include="Schema\JsonSchemaReference.cs" />
+    <Compile Include="Schema\JsonSchemaTypeDefinition.cs" />
+    <Compile Include="Schema\JsonSchemaTypeDefinitionCollection.cs" />
+    <Compile Include="Schema\StringSchema.cs" />
     <Compile Include="Serialization\Internal\ITypeSerializer.cs" />
     <Compile Include="Serialization\Internal\PropertyReference.cs" />
     <Compile Include="Helpers\XmlNamespaceRegistry.cs" />
     <Compile Include="Serialization\Internal\ISerializerFactory.cs" />
     <Compile Include="Serialization\Internal\JsonCompatibleSerializer.cs" />
     <Compile Include="Serialization\Internal\ReferencingSerializer.cs" />
+    <Compile Include="Serialization\Internal\SchemaSerializer.cs" />
     <Compile Include="Serialization\Internal\SerializationPair.cs" />
     <Compile Include="Serialization\Internal\SerializationPairCache.cs" />
     <Compile Include="Serialization\Internal\SerializerFactory.cs" />
   <ItemGroup>
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

File Manatee.Json/Schema/AllOfSchema.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:		AllOfSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		AllOfSchema
+	Purpose:		Used to define a collection of schema conditions, all of which
+					must be satisfied.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Used to define a collection of schema conditions, all of which must be satisfied.
+	/// </summary>
+	public class AllOfSchema : IJsonSchema
+	{
+		/// <summary>
+		/// A collection of required schema which must be satisfied.
+		/// </summary>
+		public IEnumerable<IJsonSchema> Requirements { get; set; }
+		/// <summary>
+		/// The default value for this schema.
+		/// </summary>
+		/// <remarks>
+		/// The default value is defined as a JSON value which may need to be deserialized
+		/// to a .Net data structure.
+		/// </remarks>
+		public JsonValue Default { get; set; }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			var obj = json.Object;
+			Requirements = obj["allOf"].Array.Select(JsonSchemaFactory.FromJson);
+			if (obj.ContainsKey("default")) Default = obj["default"];
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			var json = new JsonObject {{"allOf", Requirements.ToJson()}};
+			if (Default != null) json["default"] = Default;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/AnyOfSchema.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:		AnyOfSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		AnyOfSchema
+	Purpose:		Used to define a collection of schema conditions, any number of
+					which may be satisfied.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Used to define a collection of schema conditions, any number of which may
+	/// be satisfied.
+	/// </summary>
+	public class AnyOfSchema : IJsonSchema
+	{
+		/// <summary>
+		/// A collection of schema options.
+		/// </summary>
+		public IEnumerable<IJsonSchema> Options { get; set; }
+		/// <summary>
+		/// The default value for this schema.
+		/// </summary>
+		/// <remarks>
+		/// The default value is defined as a JSON value which may need to be deserialized
+		/// to a .Net data structure.
+		/// </remarks>
+		public JsonValue Default { get; set; }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			var obj = json.Object;
+			Options = obj["anyOf"].Array.Select(JsonSchemaFactory.FromJson);
+			if (obj.ContainsKey("default")) Default = obj["default"];
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			var json = new JsonObject {{"anyOf", Options.ToJson()}};
+			if (Default != null) json["default"] = Default;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/ArraySchema.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:		ArraySchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		ArraySchema
+	Purpose:		Defines a schema which expects an array.
+
+***************************************************************************************/
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects an array.
+	/// </summary>
+	public class ArraySchema : JsonSchema
+	{
+		/// <summary>
+		/// Gets and sets a minimum number of items required for the array.
+		/// </summary>
+		public uint? MinItems { get; set; }
+		/// <summary>
+		/// Defines a maximum number of items required for the array.
+		/// </summary>
+		public uint? MaxItems { get; set; }
+		/// <summary>
+		/// Defines the schema for the items contained in the array.
+		/// </summary>
+		public IJsonSchema Items { get; set; }
+		/// <summary>
+		/// Defines whether the array should contain only unique items.
+		/// </summary>
+		public bool UniqueItems { get; set; }
+
+		/// <summary>
+		/// Creates a new instance of the <see cref="ArraySchema"/> class.
+		/// </summary>
+		public ArraySchema() : base(JsonSchemaTypeDefinition.Array) {}
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public override void FromJson(JsonValue json)
+		{
+			base.FromJson(json);
+			var obj = json.Object;
+			MinItems = (uint?)obj.TryGetNumber("minItems");
+			MaxItems = (uint?)obj.TryGetNumber("maxItems");
+			if (obj.ContainsKey("items")) Items = JsonSchemaFactory.FromJson(obj["items"]);
+			if (obj.ContainsKey("uniqueItems")) UniqueItems = obj["uniqueItems"].Boolean;
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public override JsonValue ToJson()
+		{
+			var json = base.ToJson().Object;
+			if (Items != null) json["items"] = Items.ToJson();
+			if (MinItems.HasValue) json["minItems"] = MinItems;
+			if (MaxItems.HasValue) json["maxItems"] = MinItems;
+			if (UniqueItems) json["uniqueItems"] = UniqueItems;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/BooleanSchema.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:		BooleanSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		BooleanSchema
+	Purpose:		Defines a schema which expects an boolean value.
+
+***************************************************************************************/
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects an boolean value.
+	/// </summary>
+	public class BooleanSchema : JsonSchema
+	{
+		/// <summary>
+		/// Creates a new instance of the <see cref="BooleanSchema"/> class.
+		/// </summary>
+		public BooleanSchema() : base(JsonSchemaTypeDefinition.Boolean) { }
+		
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public override JsonValue ToJson()
+		{
+			var json = base.ToJson().Object;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/EnumSchema.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:		EnumSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		EnumSchema
+	Purpose:		Defines a schema which expects one of an explicit list of values.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects one of an explicit list of values.
+	/// </summary>
+	public class EnumSchema : IJsonSchema
+	{
+		/// <summary>
+		/// A collection of acceptable values.
+		/// </summary>
+		public IEnumerable<JsonSchemaTypeDefinition> Values { get; set; }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			Values = json.Object["enum"].Array.Select(v =>
+				{
+					var defn = new JsonSchemaTypeDefinition();
+					defn.FromJson(v);
+					return defn;
+				});
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			return new JsonObject {{"enum", Values.ToJson()}};
+		}
+	}
+}

File Manatee.Json/Schema/IJsonSchema.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:		IJsonSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		IJsonSchema
+	Purpose:		Defines a type for all schema to implement.
+
+***************************************************************************************/
+using Manatee.Json.Serialization;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a type for all schema to implement.
+	/// </summary>
+	public interface IJsonSchema : IJsonCompatible {}
+}

File Manatee.Json/Schema/IntegerSchema.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:		IntegerSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		IntegerSchema
+	Purpose:		Defines a schema which expects an integer.
+
+***************************************************************************************/
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects an integer.
+	/// </summary>
+	public class IntegerSchema : JsonSchema
+	{
+		/// <summary>
+		/// Defines a minimum acceptable value.
+		/// </summary>
+		public int? Minimum { get; set; }
+		/// <summary>
+		/// Defines a maximum acceptable value;
+		/// </summary>
+		public int? Maximum { get; set; }
+		/// <summary>
+		/// Defines whether the minimum value is itself acceptable.
+		/// </summary>
+		public bool ExclusiveMinimum { get; set; }
+		/// <summary>
+		/// Defines whether the maximum value is itself acceptable.
+		/// </summary>
+		public bool ExclusiveMaximum { get; set; }
+
+		/// <summary>
+		/// Creates a new instance of the <see cref="IntegerSchema"/> class.
+		/// </summary>
+		public IntegerSchema() : base(JsonSchemaTypeDefinition.Integer) {}
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public override void FromJson(JsonValue json)
+		{
+			base.FromJson(json);
+			var obj = json.Object;
+			Minimum = (int?) obj.TryGetNumber("minimum");
+			Maximum = (int?) obj.TryGetNumber("maximum");
+			if (obj.ContainsKey("exclusiveMinimum")) ExclusiveMinimum = obj["exclusiveMinimum"].Boolean;
+			if (obj.ContainsKey("exclusiveMaximum")) ExclusiveMaximum = obj["minimum"].Boolean;
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public override JsonValue ToJson()
+		{
+			var json = base.ToJson().Object;
+			if (Minimum.HasValue) json["minimum"] = Minimum;
+			if (Maximum.HasValue) json["maximum"] = Maximum;
+			if (ExclusiveMinimum) json["exclusiveMinimum"] = ExclusiveMinimum;
+			if (ExclusiveMaximum) json["exclusiveMaximum"] = ExclusiveMaximum;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchema.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:		JsonSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchema
+	Purpose:		Provides base functionality for the basic ISchema implementations.
+
+***************************************************************************************/
+
+using System;
+using System.Collections.Generic;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Provides base functionality for the basic ISchema implementations.
+	/// </summary>
+	public class JsonSchema : IJsonSchema
+	{
+		/// <summary>
+		/// Defines an empty Schema.  Useful for specifying that any schema is valid.
+		/// </summary>
+		public static readonly JsonSchema Empty = new JsonSchema();
+		/// <summary>
+		/// Defines the Draft-04 Schema as presented at http://json-schema.org/draft-04/schema#
+		/// </summary>
+		public static readonly JsonSchema Draft04 = new ObjectSchema
+			{
+				Id = "http://json-schema.org/draft-04/schema#",
+				Schema = "http://json-schema.org/draft-04/schema#",
+				Description = "Core schema meta-schema",
+				Definitions = new JsonSchemaTypeDefinitionCollection
+					{
+						new JsonSchemaTypeDefinition("schemaArray")
+							{
+								Definition = new ArraySchema {MinItems = 1, Items = JsonSchemaReference.Self},
+							},
+						new JsonSchemaTypeDefinition("positiveInteger")
+							{
+								Definition = new IntegerSchema {Minimum = 0},
+							},
+						new JsonSchemaTypeDefinition("positiveIntegerDefault0")
+							{
+								Definition = new AllOfSchema
+									{
+										Requirements = new List<IJsonSchema>
+											{
+												new JsonSchemaReference("#/definitions/positiveInteger"),
+												new JsonSchema {Default = 0}
+											}
+									},
+							},
+						new JsonSchemaTypeDefinition("simpleTypes")
+							{
+								Definition = new EnumSchema {Values = new List<JsonSchemaTypeDefinition>
+									{
+										JsonSchemaTypeDefinition.Array,
+										JsonSchemaTypeDefinition.Boolean,
+										JsonSchemaTypeDefinition.Integer,
+										JsonSchemaTypeDefinition.Null,
+										JsonSchemaTypeDefinition.Number,
+										JsonSchemaTypeDefinition.Object,
+										JsonSchemaTypeDefinition.String
+									}}
+							},
+						new JsonSchemaTypeDefinition("stringArray")
+							{
+								Definition = new ArraySchema {Items = new StringSchema(), MinItems = 1, UniqueItems = true}
+							}
+					},
+				Properties = new JsonSchemaPropertyDefinitionCollection
+					{
+						new JsonSchemaPropertyDefinition {Name = "id", Type = new StringSchema {Format = "uri"}},
+						new JsonSchemaPropertyDefinition {Name = "$schema", Type = new StringSchema {Format = "uri"}},
+						new JsonSchemaPropertyDefinition {Name = "title", Type = new StringSchema()},
+						new JsonSchemaPropertyDefinition {Name = "description", Type = new StringSchema()},
+						new JsonSchemaPropertyDefinition {Name = "default", Type = Empty},
+						new JsonSchemaPropertyDefinition {Name = "multipleOf", Type = new NumberSchema {Minimum = 0, ExclusiveMinimum = true}},
+						new JsonSchemaPropertyDefinition {Name = "maximum", Type = new NumberSchema()},
+						new JsonSchemaPropertyDefinition {Name = "exclusiveMaximum", Type = new BooleanSchema {Default = false}},
+						new JsonSchemaPropertyDefinition {Name = "minimum", Type = new NumberSchema()},
+						new JsonSchemaPropertyDefinition {Name = "exclusiveMinimum", Type = new BooleanSchema {Default = false}},
+						new JsonSchemaPropertyDefinition {Name = "maxLength", Type = new JsonSchemaReference("#/definitions/positiveInteger")},
+						new JsonSchemaPropertyDefinition {Name = "minLength", Type = new JsonSchemaReference("#/definitions/positiveIntegerDefault0")},
+						new JsonSchemaPropertyDefinition {Name = "pattern", Type = new StringSchema {Format = "regex"}},
+						new JsonSchemaPropertyDefinition {Name = "additionalItems", Type = new AnyOfSchema
+							{
+								Options = new List<IJsonSchema> {new BooleanSchema(), JsonSchemaReference.Self},
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "items", Type = new AnyOfSchema
+							{
+								Options = new List<IJsonSchema> {JsonSchemaReference.Self, new JsonSchemaReference("#/definitions/schemaArray")},
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "maxItems", Type = new JsonSchemaReference("#/definitions/positiveInteger")},
+						new JsonSchemaPropertyDefinition {Name = "minItems", Type = new JsonSchemaReference("#/definitions/positiveIntegerDefault0")},
+						new JsonSchemaPropertyDefinition {Name = "uniqueItems", Type = new BooleanSchema {Default = false}},
+						new JsonSchemaPropertyDefinition {Name = "maxProperties", Type = new JsonSchemaReference("#/definitions/positiveInteger")},
+						new JsonSchemaPropertyDefinition {Name = "minProperties", Type = new JsonSchemaReference("#/definitions/positiveIntegerDefault0")},
+						new JsonSchemaPropertyDefinition {Name = "required", Type = new JsonSchemaReference("#/definitions/stringArray")},
+						new JsonSchemaPropertyDefinition {Name = "additionalProperties", Type = new AnyOfSchema
+							{
+								Options = new List<IJsonSchema> {new BooleanSchema(), JsonSchemaReference.Self},
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "definitions", Type = new ObjectSchema
+							{
+								AdditionalProperties = JsonSchemaReference.Self,
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "properties", Type = new ObjectSchema
+							{
+								AdditionalProperties = JsonSchemaReference.Self,
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "patternProperties", Type = new ObjectSchema
+							{
+								AdditionalProperties = JsonSchemaReference.Self,
+								Default = new JsonObject()
+							}},
+						new JsonSchemaPropertyDefinition {Name = "dependencies", Type = new ObjectSchema
+							{
+								AdditionalProperties = new AnyOfSchema
+									{
+										Options = new List<IJsonSchema>
+											{
+												JsonSchemaReference.Self,
+												new JsonSchemaReference("#/definitions/stringArray")
+											}
+									}
+							}},
+						new JsonSchemaPropertyDefinition {Name = "enum", Type = new ArraySchema {MinItems = 1, UniqueItems = true}},
+						new JsonSchemaPropertyDefinition {Name = "type", Type = new AnyOfSchema
+							{
+								Options = new List<IJsonSchema>
+									{
+										new JsonSchemaReference("#/definitions/simpleTypes"),
+										new ArraySchema {Items = new JsonSchemaReference("#/definitions/simpleTypes"), MinItems = 1, UniqueItems = true}
+									}
+							}},
+						new JsonSchemaPropertyDefinition {Name = "allOf", Type = new JsonSchemaReference("#/definitions/schemaArray")},
+						new JsonSchemaPropertyDefinition {Name = "anyOf", Type = new JsonSchemaReference("#/definitions/schemaArray")},
+						new JsonSchemaPropertyDefinition {Name = "oneOf", Type = new JsonSchemaReference("#/definitions/schemaArray")},
+						new JsonSchemaPropertyDefinition {Name = "not", Type = JsonSchemaReference.Self},
+					},
+				Dependencies = new Dictionary<string, IEnumerable<string>>
+					{
+						{"exclusiveMaximum", new List<string> {"maximum"}},
+						{"exclusiveMinimum", new List<string> {"minimum"}}
+					},
+				Default = new JsonObject()
+			};
+
+		/// <summary>
+		/// The JSON Schema type which defines this schema.
+		/// </summary>
+		public JsonSchemaTypeDefinition Type { get; private set; }
+		/// <summary>
+		/// The default value for this schema.
+		/// </summary>
+		/// <remarks>
+		/// The default value is defined as a JSON value which may need to be deserialized
+		/// to a .Net data structure.
+		/// </remarks>
+		public JsonValue Default { get; set; }
+
+		internal JsonSchema() {}
+		/// <summary>
+		/// Creates a new instance of the indicated type.
+		/// </summary>
+		/// <param name="type">The JSON Schema type which defines this schema.</param>
+		public JsonSchema(JsonSchemaTypeDefinition type)
+		{
+			if (type == null)
+				throw new ArgumentNullException("type");
+			Type = type;
+		}
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public virtual void FromJson(JsonValue json)
+		{
+			var obj = json.Object;
+			if (obj.ContainsKey("type"))
+			{
+				switch (obj["type"].String)
+				{
+					case "array":
+						Type = JsonSchemaTypeDefinition.Array;
+						break;
+					case "boolean":
+						Type = JsonSchemaTypeDefinition.Boolean;
+						break;
+					case "integer":
+						Type = JsonSchemaTypeDefinition.Integer;
+						break;
+					case "null":
+						Type = JsonSchemaTypeDefinition.Null;
+						break;
+					case "number":
+						Type = JsonSchemaTypeDefinition.Number;
+						break;
+					case "object":
+						Type = JsonSchemaTypeDefinition.Object;
+						break;
+					case "string":
+						Type = JsonSchemaTypeDefinition.String;
+						break;
+				}
+			}
+			if (obj.ContainsKey("default")) Default = obj["default"];
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public virtual JsonValue ToJson()
+		{
+			var json = new JsonObject();
+			if (Type != null) json["type"] = Type.Name;
+			if (Default != null) json["default"] = Default;
+			return json;
+		}
+
+	}
+}

File Manatee.Json/Schema/JsonSchemaFactory.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:		JsonSchemaFactory.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaFactory
+	Purpose:		Defines methods to build schema objects.
+
+***************************************************************************************/
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines methods to build schema objects.
+	/// </summary>
+	public static class JsonSchemaFactory
+	{
+		/// <summary>
+		/// Creates a schema object from its JSON representation.
+		/// </summary>
+		/// <param name="json">A JSON object.</param>
+		/// <returns>A schema object</returns>
+		public static IJsonSchema FromJson(JsonValue json)
+		{
+			if (json == null) return null;
+			IJsonSchema schema = new JsonSchema();
+			var obj = json.Object;
+			if (obj.ContainsKey("type"))
+			{
+				switch (obj["type"].String)
+				{
+					case "array":
+						schema = new ArraySchema();
+						break;
+					case "boolean":
+						schema = new BooleanSchema();
+						break;
+					case "integer":
+						schema = new IntegerSchema();
+						break;
+					case "null":
+						schema = new NullSchema();
+						break;
+					case "number":
+						schema = new NumberSchema();
+						break;
+					case "object":
+						schema = new ObjectSchema();
+						break;
+					case "string":
+						schema = new StringSchema();
+						break;
+				}
+			}
+			else if (obj.ContainsKey("$ref"))
+			{
+				// if has "$ref" key, select SchemaReference
+				schema = new JsonSchemaReference();
+			}
+			else if (obj.ContainsKey("anyOf"))
+			{
+				// if has "anyOf" key, select AnyOfSchema
+				schema = new AnyOfSchema();
+			}
+			else if (obj.ContainsKey("allOf"))
+			{
+				// if has "allOf" key, select AllOfSchema
+				schema = new AllOfSchema();
+			}
+			else if (obj.ContainsKey("oneOf"))
+			{
+				// if has "oneOf" key, select OneOfSchema
+				schema = new OneOfSchema();
+			}
+			else if (obj.ContainsKey("not"))
+			{
+				// if has "not" key, select NotSchema
+				schema = new NotSchema();
+			}
+			else if (obj.ContainsKey("enum"))
+			{
+				// if has "not" key, select NotSchema
+				schema = new EnumSchema();
+			}
+			schema.FromJson(json);
+			return schema;
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchemaPropertyDefinition.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:		JsonSchemaPropertyDefinition.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaPropertyDefinition
+	Purpose:		Defines a single property within a schema.
+
+***************************************************************************************/
+using System.Linq;
+using Manatee.Json.Serialization;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a single property within a schema.
+	/// </summary>
+	public class JsonSchemaPropertyDefinition : IJsonCompatible
+	{
+		/// <summary>
+		/// Defines the name of the property.
+		/// </summary>
+		public string Name { get; set; }
+		/// <summary>
+		/// Defines a schema used to represent the type of this property.
+		/// </summary>
+		public IJsonSchema Type { get; set; }
+		/// <summary>
+		/// Defines whether this property is required.
+		/// </summary>
+		public bool IsRequired { get; set; }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			var details = json.Object.First();
+			Name = details.Key;
+			Type = JsonSchemaFactory.FromJson(details.Value);
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			return new JsonObject {{Name, Type.ToJson()}};
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchemaPropertyDefinitionCollection.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:		JsonSchemaPropertyDefinitionCollection.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaPropertyDefinitionCollection
+	Purpose:		Defines a collection of properties within a schema.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a collection of properties within a schema.
+	/// </summary>
+	public class JsonSchemaPropertyDefinitionCollection : List<JsonSchemaPropertyDefinition>
+	{
+		/// <summary>
+		/// Retrieves a schema property by name.
+		/// </summary>
+		/// <param name="name">The name of the property.</param>
+		/// <returns>The requested property or null if it does not exist.</returns>
+		public JsonSchemaPropertyDefinition this[string name]
+		{
+			get { return this.FirstOrDefault(p => p.Name == name); }
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchemaReference.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:		JsonSchemaReference.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaReference
+	Purpose:		Defines a reference to a schema.
+
+***************************************************************************************/
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a reference to a schema.
+	/// </summary>
+	public class JsonSchemaReference : IJsonSchema
+	{
+		/// <summary>
+		/// Defines a reference to the root schema.
+		/// </summary>
+		public static readonly JsonSchemaReference Self = new JsonSchemaReference("#");
+
+		private JsonSchema _schema;
+
+		/// <summary>
+		/// Defines the reference in respect to the root schema.
+		/// </summary>
+		public string Reference { get; private set; }
+		/// <summary>
+		/// Exposes the schema at the references location.
+		/// </summary>
+		/// <remarks>
+		/// The <see cref="Resolve"/> method must first be called.
+		/// </remarks>
+		public virtual JsonSchema Resolved { get { return _schema; } }
+
+		internal JsonSchemaReference() {}
+		/// <summary>
+		/// Creates a new instance of the <see cref="JsonSchemaReference"/> class.
+		/// </summary>
+		/// <param name="reference"></param>
+		public JsonSchemaReference(string reference)
+		{
+			Reference = reference;
+		}
+
+		/// <summary>
+		/// Resolves the reference in relation to a specific root.
+		/// </summary>
+		/// <param name="root"></param>
+		public void Resolve(JsonSchema root)
+		{
+			_schema = null;
+		}
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			Reference = json.Object["$ref"].String;
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			return new JsonObject {{"$ref", Reference}};
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchemaTypeDefinition.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:		JsonSchemaTypeDefinition.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaTypeDefinition
+	Purpose:		Defines a single type definition within a schema.
+
+***************************************************************************************/
+using System.Linq;
+using Manatee.Json.Enumerations;
+using Manatee.Json.Serialization;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a single type definition within a schema.
+	/// </summary>
+	public class JsonSchemaTypeDefinition : IJsonCompatible
+	{
+		/// <summary>
+		/// Defines the array type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Array = new JsonSchemaTypeDefinition("array");
+		/// <summary>
+		/// Defines the boolean type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Boolean = new JsonSchemaTypeDefinition("boolean");
+		/// <summary>
+		/// Defines the integer type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Integer = new JsonSchemaTypeDefinition("integer");
+		/// <summary>
+		/// Defines the null type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Null = new JsonSchemaTypeDefinition("null");
+		/// <summary>
+		/// Defines the number type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Number = new JsonSchemaTypeDefinition("number");
+		/// <summary>
+		/// Defines the object type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition Object = new JsonSchemaTypeDefinition("object");
+		/// <summary>
+		/// Defines the string type.
+		/// </summary>
+		public static readonly JsonSchemaTypeDefinition String = new JsonSchemaTypeDefinition("string");
+
+		/// <summary>
+		/// Defines the name of the type.
+		/// </summary>
+		public string Name { get; private set; }
+		/// <summary>
+		/// Defines a schema used to define the type.
+		/// </summary>
+		public IJsonSchema Definition { get; set; }
+
+		internal JsonSchemaTypeDefinition() {}
+		/// <summary>
+		/// Creates a new instance of the <see cref="JsonSchemaTypeDefinition"/> type.
+		/// </summary>
+		/// <param name="name">The name of the type.</param>
+		public JsonSchemaTypeDefinition(string name)
+		{
+			Name = name;
+		}
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			if (json.Type == JsonValueType.String)
+			{
+				Name = json.String;
+				return;
+			}
+			var details = json.Object.First();
+			Name = details.Key;
+			Definition = JsonSchemaFactory.FromJson(details.Value);
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			if (Definition == null)
+				return Name;
+			return new JsonObject {{Name, Definition.ToJson()}};
+		}
+	}
+}

File Manatee.Json/Schema/JsonSchemaTypeDefinitionCollection.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:		JsonSchemaTypeDefinitionCollection.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		JsonSchemaTypeDefinitionCollection
+	Purpose:		Defines a collection of type definitions within a schema.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a collection of type definitions within a schema.
+	/// </summary>
+	public class JsonSchemaTypeDefinitionCollection : List<JsonSchemaTypeDefinition>
+	{
+		/// <summary>
+		/// Retrieves a schema type definition by name.
+		/// </summary>
+		/// <param name="name">The name of the type definition.</param>
+		/// <returns>The requested type definition or null if it does not exist.</returns>
+		public JsonSchemaTypeDefinition this[string name]
+		{
+			get { return this.FirstOrDefault(p => p.Name == name); }
+		}
+	}
+}

File Manatee.Json/Schema/NotSchema.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:		AnyOfSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		AnyOfSchema
+	Purpose:		Used to define a collection of schema conditions, none of
+					which may be satisfied.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Used to define a collection of schema conditions, none of which may be satisfied.
+	/// </summary>
+	public class NotSchema : IJsonSchema
+	{
+		/// <summary>
+		/// A collection of schema which must not be satisfied.
+		/// </summary>
+		public IEnumerable<IJsonSchema> Restrictions { get; set; }
+		/// <summary>
+		/// The default value for this schema.
+		/// </summary>
+		/// <remarks>
+		/// The default value is defined as a JSON value which may need to be deserialized
+		/// to a .Net data structure.
+		/// </remarks>
+		public JsonValue Default { get; set; }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public void FromJson(JsonValue json)
+		{
+			var obj = json.Object;
+			Restrictions = obj["not"].Array.Select(JsonSchemaFactory.FromJson);
+			if (obj.ContainsKey("default")) Default = obj["default"];
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public JsonValue ToJson()
+		{
+			var json = new JsonObject {{"not", Restrictions.ToJson()}};
+			if (Default != null) json["default"] = Default;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/NullSchema.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:		BooleanSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		BooleanSchema
+	Purpose:		Defines a schema which expects a null value.
+
+***************************************************************************************/
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects a null value.
+	/// </summary>
+	public class NullSchema : JsonSchema
+	{
+		/// <summary>
+		/// Creates an instance of the <see cref="NullSchema"/> class.
+		/// </summary>
+		public NullSchema() : base(JsonSchemaTypeDefinition.Null) {}
+	}
+}

File Manatee.Json/Schema/NumberSchema.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:		NumberSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		NumberSchema
+	Purpose:		Defines a schema which expects a number.
+
+***************************************************************************************/
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects a number.
+	/// </summary>
+	public class NumberSchema : JsonSchema
+	{
+		/// <summary>
+		/// Defines a minimum acceptable value.
+		/// </summary>
+		public double? Minimum { get; set; }
+		/// <summary>
+		/// Defines a maximum acceptable value;
+		/// </summary>
+		public double? Maximum { get; set; }
+		/// <summary>
+		/// Defines whether the minimum value is itself acceptable.
+		/// </summary>
+		public bool ExclusiveMinimum { get; set; }
+		/// <summary>
+		/// Defines whether the maximum value is itself acceptable.
+		/// </summary>
+		public bool ExclusiveMaximum { get; set; }
+
+		/// <summary>
+		/// Creates a new instance of the <see cref="NumberSchema"/> class.
+		/// </summary>
+		public NumberSchema() : base(JsonSchemaTypeDefinition.Number) { }
+
+		/// <summary>
+		/// Builds an object from a JsonValue.
+		/// </summary>
+		/// <param name="json">The JsonValue representation of the object.</param>
+		public override void FromJson(JsonValue json)
+		{
+			base.FromJson(json);
+			var obj = json.Object;
+			Minimum = obj.TryGetNumber("minimum");
+			Maximum = obj.TryGetNumber("maximum");
+			if (obj.ContainsKey("exclusiveMinimum")) ExclusiveMinimum = obj["exclusiveMinimum"].Boolean;
+			if (obj.ContainsKey("exclusiveMaximum")) ExclusiveMaximum = obj["minimum"].Boolean;
+		}
+		/// <summary>
+		/// Converts an object to a JsonValue.
+		/// </summary>
+		/// <returns>The JsonValue representation of the object.</returns>
+		public override JsonValue ToJson()
+		{
+			var json = base.ToJson().Object;
+			if (Minimum.HasValue) json["minimum"] = Minimum;
+			if (Maximum.HasValue) json["maximum"] = Maximum;
+			if (ExclusiveMinimum) json["exclusiveMinimum"] = ExclusiveMinimum;
+			if (ExclusiveMaximum) json["exclusiveMaximum"] = ExclusiveMaximum;
+			return json;
+		}
+	}
+}

File Manatee.Json/Schema/ObjectSchema.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:		ObjectSchema.cs
+	Namespace:		Manatee.Json.Schema
+	Class Name:		ObjectSchema
+	Purpose:		Defines a schema which expects an object.
+
+***************************************************************************************/
+using System.Collections.Generic;
+using System.Linq;
+using Manatee.Json.Extensions;
+
+namespace Manatee.Json.Schema
+{
+	/// <summary>
+	/// Defines a schema which expects an object.
+	/// </summary>
+	public class ObjectSchema : JsonSchema
+	{
+		/// <summary>
+		/// Used to specify which this schema defines.
+		/// </summary>
+		public string Id { get; set; }
+		/// <summary>
+		/// Used to specify a schema which contains the definitions used by this schema.
+		/// </summary>
+		/// <remarks>
+		/// if left null, the default of http://json-schema.org/draft-04/schema# is used.
+		/// </remarks>
+		public string Schema { get; set; }
+		/// <summary>
+		/// Defines a title for this schema.
+		/// </summary>
+		public string Title { get; set; }
+		/// <summary>
+		/// Defines a description for this schema.
+		/// </summary>
+		public string Description { get; set; }
+		/// <summary>
+		/// Defines a collection of schema type definitions.
+		/// </summary>
+		public JsonSchemaTypeDefinitionCollection Definitions { get; set; }
+		/// <summary>
+		/// Defines a collection of properties expected by this schema.
+		/// </summary>
+		public JsonSchemaPropertyDefinitionCollection Properties { get; set; }
+		/// <summary>
+		/// Defines any additional properties to be expected by this schema.