コード例 #1
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            uint value = GetValue(source);

            if (IsOptional && value == DefaultValue)
            {
                return(0);
            }
            return(WritePrefix(context)
                   + context.EncodeUInt32(value));
        }
コード例 #2
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            Decimal value = GetValue(source);

            if (IsOptional && value == DefaultValue)
            {
                return(0);
            }
            return(WritePrefix(context)
                   + ProtoDecimal.SerializeDecimal(value, context, false)
                   + context.EncodeUInt32(suffix));
        }
コード例 #3
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            TEntityActual value = (TEntityActual)(object)GetValue(source);

            if (value == null)
            {
                return(0);
            }

            return(WritePrefix(context)
                   + Serializer <TEntityActual> .Serialize(value, context)
                   + context.EncodeUInt32(suffix));
        }
コード例 #4
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            byte[] value = GetValue(source);
            if (value == null)
            {
                return(0);
            }
            int count = value.Length;

            int len = WritePrefix(context)
                      + context.EncodeUInt32((uint)count);

            if (count > 0)
            {
                context.WriteBlock(value, 0, count);
            }
            return(len + count);
        }
コード例 #5
0
 protected int WritePrefix(SerializationContext context)
 {
     return(suppressPrefix ? 0 : context.EncodeUInt32(FieldPrefix));
 }