Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ProtoBuf;
- using System;
- using System.IO;
- namespace ConsoleApp17
- {
- static class Program
- {
- static void Main()
- {
- // 0A-07-32-2E-30-2E-30-2E-30-18-EA-EB-B1-DF-05
- Write(new FeedHeader { GtfsRealtimeVersion = "2.0.0.0", Timestamp = GetUnixSeconds() });
- Console.WriteLine();
- // 0A-07-32-2E-30-2E-30-2E-30-18-F5-BD-B2-9D-F1-2C
- Write(new FeedHeader { GtfsRealtimeVersion = "2.0.0.0", Timestamp = GetUnixMilliseconds() });
- }
- static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- static ulong GetUnixSeconds() => (ulong)(DateTime.UtcNow - UnixEpoch).TotalSeconds;
- static ulong GetUnixMilliseconds() => (ulong)(DateTime.UtcNow - UnixEpoch).TotalMilliseconds;
- private static void Write(FeedHeader header)
- {
- using (var ms = new MemoryStream())
- {
- Serializer.Serialize(ms, header);
- Console.WriteLine(BitConverter.ToString(
- ms.GetBuffer(), 0, (int)ms.Length));
- }
- }
- }
- /*
- message FeedHeader {
- // Version of the feed specification.
- // The current version is 2.0.
- required string gtfs_realtime_version = 1;
- // Determines whether the current fetch is incremental. Currently,
- // DIFFERENTIAL mode is unsupported and behavior is unspecified for feeds
- // that use this mode. There are discussions on the GTFS Realtime mailing
- // list around fully specifying the behavior of DIFFERENTIAL mode and the
- // documentation will be updated when those discussions are finalized.
- enum Incrementality {
- FULL_DATASET = 0;
- DIFFERENTIAL = 1;
- }
- optional Incrementality incrementality = 2 [default = FULL_DATASET];
- // This timestamp identifies the moment when the content of this feed has been
- // created (in server time). In POSIX time (i.e., number of seconds since
- // January 1st 1970 00:00:00 UTC).
- optional uint64 timestamp = 3;
- // The extensions namespace allows 3rd-party developers to extend the
- // GTFS Realtime specification in order to add and evaluate new features and
- // modifications to the spec.
- extensions 1000 to 1999;
- }
- */
- // This file was generated by a tool; you should avoid making direct changes.
- // Consider using 'partial classes' to extend these types
- // Input: my.proto
- #pragma warning disable CS1591, CS0612, CS3021, IDE1006
- [global::ProtoBuf.ProtoContract()]
- public partial class FeedHeader : 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 = @"gtfs_realtime_version", IsRequired = true)]
- public string GtfsRealtimeVersion { get; set; }
- [global::ProtoBuf.ProtoMember(2)]
- [global::System.ComponentModel.DefaultValue(Incrementality.FullDataset)]
- public Incrementality incrementality
- {
- get { return __pbn__incrementality ?? Incrementality.FullDataset; }
- set { __pbn__incrementality = value; }
- }
- public bool ShouldSerializeincrementality() => __pbn__incrementality != null;
- public void Resetincrementality() => __pbn__incrementality = null;
- private Incrementality? __pbn__incrementality;
- [global::ProtoBuf.ProtoMember(3, Name = @"timestamp")]
- public ulong Timestamp
- {
- get { return __pbn__Timestamp.GetValueOrDefault(); }
- set { __pbn__Timestamp = value; }
- }
- public bool ShouldSerializeTimestamp() => __pbn__Timestamp != null;
- public void ResetTimestamp() => __pbn__Timestamp = null;
- private ulong? __pbn__Timestamp;
- [global::ProtoBuf.ProtoContract()]
- public enum Incrementality
- {
- [global::ProtoBuf.ProtoEnum(Name = @"FULL_DATASET")]
- FullDataset = 0,
- [global::ProtoBuf.ProtoEnum(Name = @"DIFFERENTIAL")]
- Differential = 1,
- }
- }
- #pragma warning restore CS1591, CS0612, CS3021, IDE1006
- }
Add Comment
Please, Sign In to add comment