Skip to content

Instantly share code, notes, and snippets.

@mgravell
Created September 8, 2021 13:30
Show Gist options
  • Save mgravell/982a49250aa1b50a4706db3bbda40420 to your computer and use it in GitHub Desktop.
Save mgravell/982a49250aa1b50a4706db3bbda40420 to your computer and use it in GitHub Desktop.
using ProtoBuf;
using System;
static class Program
{
static void Main()
{
ReadOnlyMemory<byte> bytes = Convert.FromBase64String("CgYI3KzdiQYQidgLGgAgZiokNzk4M2Y0YjAtYjQ3My00NTY1LTkyMWUtMzI5NDk3YjAwMzQy");
var finalValue = Serializer.Deserialize<ileco.chimp.proto.FinalValue>(bytes);
Console.WriteLine(finalValue.inputGuid); // 7983f4b0-b473-4565-921e-329497b00342
Console.WriteLine(finalValue.inputId); // 191497
Console.WriteLine(finalValue.sourceId); // 102
Console.WriteLine(finalValue.Timestamp); // 07/09/2021 12:09:00
Console.WriteLine(finalValue.Value?.Value); // 0
}
}
namespace Google.Protobuf.WellKnownTypes
{
[ProtoContract]
public sealed class DoubleValue
{
[ProtoMember(1)]
public double Value { get; set; }
}
}
// <auto-generated>
// This file was generated by a tool; you should avoid making direct changes.
// Consider using 'partial classes' to extend these types
// Input: my.proto
// </auto-generated>
#region Designer generated code
#pragma warning disable CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192
namespace ileco.chimp.proto
{
[global::ProtoBuf.ProtoContract()]
public partial class FinalValue : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
=> global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
[global::ProtoBuf.ProtoMember(1, Name = @"timestamp", DataFormat = global::ProtoBuf.DataFormat.WellKnown)]
public global::System.DateTime? Timestamp { get; set; }
[global::ProtoBuf.ProtoMember(2)]
public uint inputId { get; set; }
[global::ProtoBuf.ProtoMember(3, Name = @"value")]
public global::Google.Protobuf.WellKnownTypes.DoubleValue Value { get; set; }
[global::ProtoBuf.ProtoMember(4)]
public uint sourceId { get; set; }
[global::ProtoBuf.ProtoMember(5)]
[global::System.ComponentModel.DefaultValue("")]
public string inputGuid { get; set; } = "";
}
}
#pragma warning restore CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment