private static void Merge(ref ProtoReader.State state, ref protogen.OrderLine obj) { int field; if (obj == null) { obj = new protogen.OrderLine(); } while ((field = state.ReadFieldHeader()) != 0) { switch (field) { case 1: obj.OrderID = state.ReadInt32(); break; case 2: obj.ProductID = state.ReadInt32(); break; case 3: obj.UnitPrice = state.ReadDouble(); break; case 4: state.Hint(WireType.SignedVarint); obj.Quantity = state.ReadInt32(); break; case 5: obj.Discount = state.ReadSingle(); break; default: state.AppendExtensionData(obj); break; } } }