Beispiel #1
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            long value = GetValue(source);

            if (IsOptional && value == DefaultValue)
            {
                return(0);
            }
            return(WritePrefix(context) + context.EncodeInt64Fixed(value));
        }
Beispiel #2
0
        public override int Serialize(TSource source, SerializationContext context)
        {
            DateTime value = GetValue(source);

            if (IsOptional && value == DefaultValue)
            {
                return(0);
            }
            long ticks = (value - ProtoTimeSpan.EpochOrigin).Ticks;

            return(WritePrefix(context) + context.EncodeInt64Fixed(ticks));
        }