public Soyo.Proto.ProtoTestClass Merge(ProtoReader input, Soyo.Proto.ProtoTestClass value) { int oldLimit = input.ReadClassBegin(); while (input.HasField) { switch (input.FieldId) { case 1: value.id = input.Merge(value.id); break; case 2: value.items = input.Merge(value.items); break; default: input.SkipField(); break; } } input.ReadClassEnd(oldLimit); return(value); }
public object Read(object value, ProtoReader source) { if (isRootType && value != null) { Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); } int fieldNumber, lastFieldNumber = 0, lastFieldIndex = 0; bool fieldHandled; //Helpers.DebugWriteLine(">> Reading fields for " + forType.FullName); while ((fieldNumber = source.ReadFieldHeader()) > 0) { fieldHandled = false; if (fieldNumber < lastFieldNumber) { lastFieldNumber = lastFieldIndex = 0; } for (int i = lastFieldIndex; i < fieldNumbers.Length; i++) { if (fieldNumbers[i] == fieldNumber) { IProtoSerializer ser = serializers[i]; //Helpers.DebugWriteLine(": " + ser.ToString()); Type serType = ser.ExpectedType; if (value == null) { if (serType == forType) { value = CreateInstance(source, true); } } else { if (serType != forType && ((IProtoTypeSerializer)ser).CanCreateInstance() && serType #if WINRT .GetTypeInfo() #endif .IsSubclassOf(value.GetType())) { value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)ser).CreateInstance(source)); } } if (ser.ReturnsValue) { value = ser.Read(value, source); } else { // pop ser.Read(value, source); } lastFieldIndex = i; lastFieldNumber = fieldNumber; fieldHandled = true; break; } } if (!fieldHandled) { //Helpers.DebugWriteLine(": [" + fieldNumber + "] (unknown)"); if (value == null) { value = CreateInstance(source, true); } if (isExtensible) { source.AppendExtensionData((IExtensible)value); } else { source.SkipField(); } } } //Helpers.DebugWriteLine("<< Reading fields for " + forType.FullName); if (value == null) { value = CreateInstance(source, true); } if (isRootType) { Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); } return(value); }
public object Read(object value, ProtoReader source) { if (isRootType && value != null) { Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); } int num = 0; int num2 = 0; int num3; while ((num3 = source.ReadFieldHeader()) > 0) { bool flag = false; if (num3 < num) { num = (num2 = 0); } for (int i = num2; i < fieldNumbers.Length; i++) { if (fieldNumbers[i] != num3) { continue; } IProtoSerializer protoSerializer = serializers[i]; Type expectedType = protoSerializer.ExpectedType; if (value == null) { if (expectedType == forType) { value = CreateInstance(source, includeLocalCallback: true); } } else if (expectedType != forType && ((IProtoTypeSerializer)protoSerializer).CanCreateInstance() && expectedType.IsSubclassOf(value.GetType())) { value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)protoSerializer).CreateInstance(source)); } if (protoSerializer.ReturnsValue) { value = protoSerializer.Read(value, source); } else { protoSerializer.Read(value, source); } num2 = i; num = num3; flag = true; break; } if (!flag) { if (value == null) { value = CreateInstance(source, includeLocalCallback: true); } if (isExtensible) { source.AppendExtensionData((IExtensible)value); } else { source.SkipField(); } } } if (value == null) { value = CreateInstance(source, includeLocalCallback: true); } if (isRootType) { Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); } return(value); }
public object Read(object value, ProtoReader source) { int num; if (this.isRootType && (value != null)) { this.Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); } int num2 = 0; int num3 = 0; while ((num = source.ReadFieldHeader()) > 0) { bool flag = false; if (num < num2) { num2 = num3 = 0; } for (int i = num3; i < this.fieldNumbers.Length; i++) { if (this.fieldNumbers[i] == num) { IProtoSerializer serializer = this.serializers[i]; Type expectedType = serializer.ExpectedType; if (value == null) { if (expectedType == this.forType) { value = this.CreateInstance(source, true); } } else if (((expectedType != this.forType) && ((IProtoTypeSerializer)serializer).CanCreateInstance()) && expectedType.IsSubclassOf(value.GetType())) { value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)serializer).CreateInstance(source)); } if (serializer.ReturnsValue) { value = serializer.Read(value, source); } else { serializer.Read(value, source); } num3 = i; num2 = num; flag = true; break; } } if (!flag) { if (value == null) { value = this.CreateInstance(source, true); } if (this.isExtensible) { source.AppendExtensionData((IExtensible)value); continue; } source.SkipField(); } } if (value == null) { value = this.CreateInstance(source, true); } if (this.isRootType) { this.Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); } return(value); }
public object Read(object value, ProtoReader source) { if (this.isRootType && value != null) { this.Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); } int num = 0; int num1 = 0; while (true) { int num2 = source.ReadFieldHeader(); int num3 = num2; if (num2 <= 0) { break; } bool flag = false; if (num3 < num) { int num4 = 0; num1 = num4; num = num4; } int num5 = num1; while (num5 < (int)this.fieldNumbers.Length) { if (this.fieldNumbers[num5] != num3) { num5++; } else { IProtoSerializer protoSerializer = this.serializers[num5]; Type expectedType = protoSerializer.ExpectedType; if (value == null) { if (expectedType == this.forType) { value = this.CreateInstance(source, true); } } else if (expectedType != this.forType && ((IProtoTypeSerializer)protoSerializer).CanCreateInstance() && expectedType.IsSubclassOf(value.GetType())) { value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)protoSerializer).CreateInstance(source)); } if (!protoSerializer.ReturnsValue) { protoSerializer.Read(value, source); } else { value = protoSerializer.Read(value, source); } num1 = num5; num = num3; flag = true; break; } } if (!flag) { if (value == null) { value = this.CreateInstance(source, true); } if (!this.isExtensible) { source.SkipField(); } else { source.AppendExtensionData((IExtensible)value); } } } if (value == null) { value = this.CreateInstance(source, true); } if (this.isRootType) { this.Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); } return(value); }
public Soyo.Proto.ProtoTestBase Merge(ProtoReader input, Soyo.Proto.ProtoTestBase value) { int oldLimit = input.ReadClassBegin(); while (input.HasField) { switch (input.FieldId) { case 1: value.byteValue = input.Merge(value.byteValue); break; case 2: value.sbyteValue = input.Merge(value.sbyteValue); break; case 3: value.shortValue = input.Merge(value.shortValue); break; case 4: value.ushortValue = input.Merge(value.ushortValue); break; case 5: value.intValue = input.MergeSign(value.intValue); break; case 6: value.uintValue = input.MergeFixed(value.uintValue); break; case 7: value.longValue = input.MergeSign(value.longValue); break; case 8: value.ulongValue = input.MergeFixed(value.ulongValue); break; case 9: value.floatValue = input.Merge(value.floatValue); break; case 10: value.doubleValue = input.Merge(value.doubleValue); break; case 11: value.enumValue = (Soyo.Proto.EnumTest)input.Merge((int)value.enumValue); break; case 12: value.stringValue = input.Merge(value.stringValue); break; case 13: value.bufferValue = input.Merge(value.bufferValue); break; case 14: value.byteArrayValue = input.Merge(value.byteArrayValue); break; case 15: value.byteNullValue = input.Merge(value.byteNullValue); break; case 16: value.sbyteNullValue = input.Merge(value.sbyteNullValue); break; case 17: value.shortNullValue = input.Merge(value.shortNullValue); break; case 18: value.ushortNullValue = input.Merge(value.ushortNullValue); break; case 19: value.intNullValue = input.Merge(value.intNullValue); break; case 20: value.uintNullValue = input.Merge(value.uintNullValue); break; case 21: value.longNullValue = input.Merge(value.longNullValue); break; case 22: value.ulongNullValue = input.Merge(value.ulongNullValue); break; case 23: value.floatNullValue = input.Merge(value.floatNullValue); break; case 24: value.doubleNullValue = input.Merge(value.doubleNullValue); break; case 25: value.bufferNullValue = input.Merge(value.bufferNullValue); break; case 26: value.boolListValue = input.Merge(value.boolListValue); break; case 27: value.byteListValue = input.Merge(value.byteListValue); break; case 28: value.sbyteListValue = input.Merge(value.sbyteListValue); break; case 29: value.shortListValue = input.Merge(value.shortListValue); break; case 30: value.ushortListValue = input.Merge(value.ushortListValue); break; case 31: value.intListValue = input.Merge(value.intListValue); break; case 32: value.uintListValue = input.Merge(value.uintListValue); break; case 33: value.longListValue = input.Merge(value.longListValue); break; case 34: value.ulongListValue = input.Merge(value.ulongListValue); break; case 35: value.floatListValue = input.Merge(value.floatListValue); break; case 36: value.doubleListValue = input.Merge(value.doubleListValue); break; case 37: value.stringListValue = input.Merge(value.stringListValue); break; case 38: value.bufferListValue = input.Merge(value.bufferListValue); break; case 39: value.byteArrayListValue = input.Merge(value.byteArrayListValue); break; case 40: value.boolValue = input.Merge(value.boolValue); break; case 41: value.boolNullValue = input.Merge(value.boolNullValue); break; case 42: value.uintUintDictionary = input.Merge(value.uintUintDictionary); break; default: input.SkipField(); break; } } input.ReadClassEnd(oldLimit); return(value); }