public void ToProto() { var timestamp = new Timestamp(1, 100); var proto = new wkt::Timestamp { Seconds = 1, Nanos = 100 }; Assert.Equal(proto, timestamp.ToProto()); }
public void FromProtoOrNull_NonNull() { var proto = new wkt::Timestamp { Seconds = 1, Nanos = 100 }; var timestamp = Timestamp.FromProtoOrNull(proto).Value; var expected = new Timestamp(1, 100); Assert.Equal(expected, timestamp); }
protected virtual object DeserializeTimestamp(FirestoreDb db, wkt::Timestamp value) => throw new ArgumentException($"Unable to convert Timestamp value to {TargetType}");
protected override object DeserializeTimestamp(FirestoreDb db, wkt::Timestamp value) => value.Clone();
protected override object DeserializeTimestamp(FirestoreDb db, wkt::Timestamp value) => value.ToDateTimeOffset();
protected override object DeserializeTimestamp(FirestoreDb db, wkt::Timestamp value) => Timestamp.FromProto(value);
/// <summary> /// Creates an instance from a Protobuf <see cref="wkt::Timestamp"/> representation /// if present, or returns a null value on null input. /// </summary> /// <param name="proto">A Protobuf timestamp representation, or null.</param> /// <returns>A null value if <paramref name="proto"/> is null; otherwise, the converted Timestamp.</returns> internal static Timestamp?FromProtoOrNull(wkt::Timestamp proto) => proto == null ? default(Timestamp?) : FromProto(proto);
/// <summary> /// Creates an instance from a Protobuf <see cref="wkt::Timestamp"/> representation. /// Later modifications to the Protobuf representation will not affect the returned oject. /// </summary> /// <param name="proto">A Protobuf timestamp representation. Must not be null.</param> /// <returns>An immutable timestamp.</returns> public static Timestamp FromProto(wkt::Timestamp proto) { GaxPreconditions.CheckNotNull(proto, nameof(proto)); return(new Timestamp(proto.Seconds, proto.Nanos)); }
protected override object DeserializeTimestamp(DeserializationContext context, wkt::Timestamp value) => value.Clone();
protected override object DeserializeTimestamp(DeserializationContext context, wkt::Timestamp value) => value.ToDateTimeOffset();
protected override object DeserializeTimestamp(DeserializationContext context, wkt::Timestamp value) => Timestamp.FromProto(value);
protected virtual object DeserializeTimestamp(DeserializationContext context, wkt::Timestamp value) => throw new ArgumentException($"Unable to convert Timestamp value to {TargetType}");
internal static WriteResult FromProto(V1Beta1.WriteResult result, wkt::Timestamp commitTime) { GaxPreconditions.CheckNotNull(result, nameof(result)); GaxPreconditions.CheckNotNull(commitTime, nameof(commitTime)); return(new WriteResult(Timestamp.FromProto(result.UpdateTime ?? commitTime))); }