Skip to content

Instantly share code, notes, and snippets.

@rofr
Created November 1, 2012 00:14
Show Gist options
  • Save rofr/3990796 to your computer and use it in GitHub Desktop.
Save rofr/3990796 to your computer and use it in GitHub Desktop.
Protobuf attributes for JournalEntry
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
[Serializable]
public abstract class JournalEntry
{
public readonly long Id;
public readonly DateTime Created;
public JournalEntry(long id, DateTime? created = null)
{
Created = created ?? DateTime.Now;
Id = id;
}
}
[ProtoContract(ImplicitFields = ImplicitFields.AllFields)]
[ProtoInclude(42, typeof(JournalEntry))]
[Serializable]
public class JournalEntry<T> : JournalEntry
{
public T Item { get; protected internal set; }
public JournalEntry(long id, T item, DateTime? created = null) : base(id, created)
{
Item = item;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment