C# Class Netduino.WebServer.Core.Json.PropertyTable

Contains a snapshot of all of the classes currently loaded by the Assembly and enumerates their class names, properties and property types into a Hashtable. The table is then referenced against a decoded Json string to determine what data types a given chunk of Json string represents. When a match is found, that class is instantiated and its properties populated with the Json data.
Show file Open project: martinbuberl/Netduino Class Usage Examples

Public Methods

Method Description
DumpObjects ( Hashtable hash, int level ) : void

Debugging/Diagnostic tool that dumps objects and their children.

FindObject ( Hashtable jsonTable ) : object

Searches the Hashtable for an object that contains a property name specified by key. The key may be composed of colon-delimited object names representing a class heirarchy.

PropertyTable ( ) : System
Snapshot ( ) : void

Takes a snapshot of the classes and their property names and types

Private Methods

Method Description
DumpObjectArray ( ArrayList array, int level ) : void
FindMatchingDictionary ( Hashtable jsonTable ) : DictionaryEntry

Searches the ArrayList of Hashtables generated at startup time, and returns the Hashtable that matches the specified Hashtable.

GetProperties ( Type types ) : Hashtable

High-level method that enumerates all Types in the loaded assembly, and places their class names and properties in a hashtable. At deserialization time, this Hashtable (containing Property Names and Types) is compared to the Hashtable containing the JSON Property Names and Values, and the result of the two Hashtables is the desired instantiated object.

GetProperty ( Type type ) : Hashtable
GetValueFromJsonHashtable ( Hashtable jsonTable, string name ) : object

Returns the Value that matches the specified name. The Value can be anything: a value type (integer, string, etc), or another class, or a Hasthtable, DictionaryEntry, or ArrayList.

SetProperty ( object parent, Type parentType, Hashtable classDefinition, DictionaryEntry entry, Hashtable jsonTable ) : void

Sets a single Property on an object. That single Property can be a Value Type, and ArrayList, Hashtable, essentially anything that's legal to deserialize. This method will recurse into itself to set all of this Property's values, children objects and values, etc.

SetTypedValue ( object parent, Type parentType, string name, string type, object unTypedValue ) : void

Performs the type conversion that is normally standard stuff for .NET, but missing in .NET MF. Basically, the unTypedValue object cannot be converted or cast using boxing or a simple cast, except for the actual Type defined inside the object (the object's Parse method ReturnType). So this function discovers what the unTypedValue's inner Type really is, compares that with the destination Property's real Type, and performs a cast specific to those two types.

Method Details

DumpObjects() public static method

Debugging/Diagnostic tool that dumps objects and their children.
public static DumpObjects ( Hashtable hash, int level ) : void
hash System.Collections.Hashtable
level int
return void

FindObject() public method

Searches the Hashtable for an object that contains a property name specified by key. The key may be composed of colon-delimited object names representing a class heirarchy.
public FindObject ( Hashtable jsonTable ) : object
jsonTable System.Collections.Hashtable
return object

PropertyTable() public method

public PropertyTable ( ) : System
return System

Snapshot() public method

Takes a snapshot of the classes and their property names and types
public Snapshot ( ) : void
return void