public static SimpleObject ReadFrom( IObjectReader reader) { SimpleObject simpleObject = null; if (reader.ReadStartObject()) { simpleObject = new SimpleObject(); int memberKey; while (reader.ReadNextMemberKey()) { memberKey = reader.MemberKey; if (memberKey == MemberKey.StringValue) { simpleObject.StringValue = reader.ReadValueAsString(StringQuotaInBytes); } else if (memberKey == MemberKey.StringEmptyValue) { simpleObject.StringEmptyValue = reader.ReadValueAsString(StringQuotaInBytes); } else if (memberKey == MemberKey.StringNullValue) { simpleObject.StringNullValue = reader.ReadValueAsString(StringQuotaInBytes); } else if (memberKey == MemberKey.ByteArrayValue) { simpleObject.ByteArrayValue = reader.ReadValueAsBytes(StringQuotaInBytes); } else if (memberKey == MemberKey.ByteArrayEmptyValue) { simpleObject.ByteArrayEmptyValue = reader.ReadValueAsBytes(StringQuotaInBytes); } else if (memberKey == MemberKey.ByteArrayNullValue) { simpleObject.ByteArrayNullValue = reader.ReadValueAsBytes(StringQuotaInBytes); } else if (memberKey == MemberKey.Int32ZeroValue) { simpleObject.Int32ZeroValue = reader.ReadValueAsInt32(); } else if (memberKey == MemberKey.Int32MinValue) { simpleObject.Int32MinValue = reader.ReadValueAsInt32(); } else if (memberKey == MemberKey.Int32MaxValue) { simpleObject.Int32MaxValue = reader.ReadValueAsInt32(); } else if (memberKey == MemberKey.UInt32MinValue) { simpleObject.UInt32MinValue = reader.ReadValueAsUInt32(); } else if (memberKey == MemberKey.UInt32MaxValue) { simpleObject.UInt32MaxValue = reader.ReadValueAsUInt32(); } else if (memberKey == MemberKey.SingleValue) { simpleObject.SingleValue = reader.ReadValueAsSingle(); } else if (memberKey == MemberKey.SingleMinValue) { simpleObject.SingleMinValue = reader.ReadValueAsSingle(); } else if (memberKey == MemberKey.SingleMaxValue) { simpleObject.SingleMaxValue = reader.ReadValueAsSingle(); } else if (memberKey == MemberKey.Int32ArrayValue) { simpleObject.Int32ArrayValue = reader.ReadValueAsInt32Array(); } else if (memberKey == MemberKey.Int32ArrayEmptyValue) { simpleObject.Int32ArrayEmptyValue = reader.ReadValueAsInt32Array(); } else if (memberKey == MemberKey.Int32ArrayNullValue) { simpleObject.Int32ArrayNullValue = reader.ReadValueAsInt32Array(); } else if (memberKey == MemberKey.StringArrayValue) { simpleObject.StringArrayValue = reader.ReadValueAsStringArray(StringQuotaInBytes); } else if (memberKey == MemberKey.StringArrayEmptyValue) { simpleObject.StringArrayEmptyValue = reader.ReadValueAsStringArray(StringQuotaInBytes); } else if (memberKey == MemberKey.StringArrayNullValue) { simpleObject.StringArrayNullValue = reader.ReadValueAsStringArray(StringQuotaInBytes); } else if (memberKey == MemberKey.StringWithEscapesValue) { simpleObject.StringWithEscapesValue = reader.ReadValueAsString(StringQuotaInBytes); } else if (memberKey == MemberKey.StringWithSurrogatePairsValue) { simpleObject.StringWithSurrogatePairsValue = reader.ReadValueAsString(StringQuotaInBytes); } else if (memberKey == MemberKey.DoubleValue) { simpleObject.DoubleValue = reader.ReadValueAsDouble(); } else if (memberKey == MemberKey.DoubleMinValue) { simpleObject.DoubleMinValue = reader.ReadValueAsDouble(); } else if (memberKey == MemberKey.DoubleMaxValue) { simpleObject.DoubleMaxValue = reader.ReadValueAsDouble(); } else if (memberKey == MemberKey.Int64ZeroValue) { simpleObject.Int64ZeroValue = reader.ReadValueAsInt64(); } else if (memberKey == MemberKey.Int64MinValue) { simpleObject.Int64MinValue = reader.ReadValueAsInt64(); } else if (memberKey == MemberKey.Int64MaxValue) { simpleObject.Int64MaxValue = reader.ReadValueAsInt64(); } else if (memberKey == MemberKey.UInt64ZeroValue) { simpleObject.UInt64ZeroValue = reader.ReadValueAsUInt64(); } else if (memberKey == MemberKey.UInt64MinValue) { simpleObject.UInt64MinValue = reader.ReadValueAsUInt64(); } else if (memberKey == MemberKey.UInt64MaxValue) { simpleObject.UInt64MaxValue = reader.ReadValueAsUInt64(); } else if (memberKey == MemberKey.BooleanTrueValue) { simpleObject.BooleanTrueValue = reader.ReadValueAsBoolean(); } else if (memberKey == MemberKey.BooleanFalseValue) { simpleObject.BooleanFalseValue = reader.ReadValueAsBoolean(); } else if (memberKey == MemberKey.BooleanArrayValue) { simpleObject.BooleanArrayValue = reader.ReadValueAsBooleanArray(); } //else //{ // Debug.WriteLine("Skipping member key {0}", memberKey); //} } reader.ReadEndObject(); } return simpleObject; }