Beispiel #1
0
 void ISubTypeSerializer <B> .WriteSubType(ref ProtoWriter.State state, B value)
 {
     if (TypeModel.IsSubType <B>(value))
     {
         if (value is C c)
         {
             state.WriteFieldHeader(5, WireType.String);
             state.WriteSubType <C>(c, this);
         }
         else
         {
             TypeModel.ThrowUnexpectedSubtype <B>(value);
         }
     }
     if (value.BVal != 0)
     {
         state.WriteFieldHeader(2, WireType.Varint);
         state.WriteInt32(value.BVal);
     }
 }
Beispiel #2
0
 void ISubTypeSerializer <A> .WriteSubType(ref ProtoWriter.State state, A value)
 {
     if (TypeModel.IsSubType <A>(value))
     {
         if (value is B b)
         {
             state.WriteFieldHeader(4, WireType.String);
             state.WriteSubType <B>(b, this);
         }
         else
         {
             TypeModel.ThrowUnexpectedSubtype <A>(value);
         }
     }
     if (value.AVal != 0)
     {
         state.WriteFieldHeader(1, WireType.Varint);
         state.WriteInt32(value.AVal);
     }
 }