public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.I32) { Id = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.String) { Description = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.Struct) { PricePerUnit = new PricePerUnit(); PricePerUnit.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.I32) { UnitId = iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.String) { UnitDescription = iprot.ReadString(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("Price"); oprot.WriteStructBegin(struc); TField field = new TField(); if (Id != null) { field.Name = "id"; field.Type = TType.I32; field.ID = 1; oprot.WriteFieldBegin(field); oprot.WriteI32(Id.Value); oprot.WriteFieldEnd(); } if (Description != null) { field.Name = "description"; field.Type = TType.String; field.ID = 2; oprot.WriteFieldBegin(field); oprot.WriteString(Description); oprot.WriteFieldEnd(); } if (PricePerUnit != null) { field.Name = "pricePerUnit"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); PricePerUnit.Write(oprot); oprot.WriteFieldEnd(); } if (UnitId != null) { field.Name = "unitId"; field.Type = TType.I32; field.ID = 4; oprot.WriteFieldBegin(field); oprot.WriteI32(UnitId.Value); oprot.WriteFieldEnd(); } if (UnitDescription != null) { field.Name = "unitDescription"; field.Type = TType.String; field.ID = 5; oprot.WriteFieldBegin(field); oprot.WriteString(UnitDescription); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }