Skip to content

Instantly share code, notes, and snippets.

@meboz
Created April 5, 2013 21:43
Show Gist options
  • Save meboz/5322871 to your computer and use it in GitHub Desktop.
Save meboz/5322871 to your computer and use it in GitHub Desktop.
simple protobuf-net with evetnstore 3 example it fails to write anything out to the commits table.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventStore;
using EventStore.Serialization;
using ProtoBuf.Meta;
namespace eventstoreprotobuf
{
class Program
{
static void Main(string[] args)
{
var store = Wireup.Init()
.UsingSqlPersistence("eventstore")
.InitializeStorageEngine()
.UsingCustomSerialization(new ProtoSerializer())
.Build();
var messageID = Guid.NewGuid();
var streamID = Guid.NewGuid();
var message = new EventMessage()
{
Body = "the body"
};
using (store)
{
// some business code here
using (var stream = store.CreateStream(streamID))
{
stream.Add(message);
stream.CommitChanges(messageID);
}
using (var stream = store.OpenStream(streamID, 0, int.MaxValue))
{
foreach (var @event in stream.CommittedEvents)
{
Console.WriteLine(@event.Body.ToString());
}
}
}
Console.ReadLine();
}
}
public class ProtoSerializer : ISerialize
{
public void Serialize<T>(Stream output, T graph)
{
ProtoBuf.Serializer.Serialize<T>(output, graph);
}
public T Deserialize<T>(Stream input)
{
return ProtoBuf.Serializer.Deserialize<T>(input);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment