/// <inheritdoc/>
 protected override void WriteValue(ref WriteContext context, DateTime value)
 {
     if (value.Kind != DateTimeKind.Utc)
     {
         value = value.ToUniversalTime();
     }
     context.WriteMessage(Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(value));
 }
 /// <inheritdoc/>
 protected override void Write(ref WriteContext writer)
 {
     if (SourceValue is IBufferMessage bufferMessage)
     {
         bufferMessage.InternalWriteTo(ref writer);
     }
     else
     {
         writer.WriteMessage(SourceValue);
     }
 }
Esempio n. 3
0
        public void WriteTo(ref WriteContext ctx, Codec codec)
        {
            var message = new Codec.MessageAdapter(codec);

            foreach (var entry in list)
            {
                message.Key   = entry.Key;
                message.Value = entry.Value;
                ctx.WriteTag(codec.MapTag);
                ctx.WriteMessage(message);
            }
        }
 /// <inheritdoc/>
 protected override void WriteValue(ref WriteContext context, TimeSpan value)
 {
     context.WriteMessage(Google.Protobuf.WellKnownTypes.Duration.FromTimeSpan(value));
 }
Esempio n. 5
0
        /// <inheritdoc/>
        protected override void WriteValue(ref WriteContext writer, T value)
        {
            Message <T> message = value;

            writer.WriteMessage(message);
        }
 /// <inheritdoc/>
 protected override void WriteValue(ref WriteContext context, DateTimeOffset value)
 {
     context.WriteMessage(Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(value));
 }