コード例 #1
0
 public static EventBlob Insert(this IDbConnection conn, EventBlob input)
 {
     return conn.GetReader("insert into [EventBlobs] " +
         "([SerializedData],[SerializationProtocol],[TypeName],[TypeFullName]) values (@p0,@p1,@p2,@p3);" +
         " select [Id],[SerializedData],[SerializationProtocol],[TypeName],[TypeFullName]"+
         " from [EventBlobs] where [Id] = SCOPE_IDENTITY();",
         input.SerializedData, input.SerializationProtocol, input.TypeName, input.TypeFullName).Select(x => x.ToEventBlob()).First();
 }
コード例 #2
0
 public bool SaveEvent(EventBlob blob, IEnumerable<EventHeader> Headers)
 {
     var res = conn.Insert(blob);
     foreach (var h in Headers)
     {
         h.EventId = res.Id;
         conn.Insert(h);
     }
     return true;
 }
コード例 #3
0
 static EventBlob ToEventBlob(this IDataReader dr)
 {
     var bl = new EventBlob();
     bl.Id = dr.GetInt32(0);
     bl.SerializedData = dr.GetString(1);
     bl.SerializationProtocol = dr.GetString(2);
     bl.TypeName = dr.GetString(3);
     bl.TypeFullName = dr.GetString(4);
     return bl;
 }
コード例 #4
0
 public bool SaveEvent(EventBlob blob, IEnumerable<EventHeader> headers)
 {
     lock (lockobj)
     {
         blob.Id = Blobs.Count + 1;
         Blobs.Add(blob);
         foreach (var h in headers)
         {
             h.EventId = blob.Id;
             Headers.Add(h);
         }
     }
     return true;
 }
コード例 #5
0
ファイル: EventStore.cs プロジェクト: rmoorman/Scritchy
 public bool SaveEvents(IEnumerable<object> events)
 {
     foreach (var evt in events)
     {
         var evtblob = new EventBlob {
             TypeFullName = evt.GetType().FullName,
             TypeName = evt.GetType().Name,
         };
         serializer.Serialize(evt, ref evtblob);
         var headers = new List<EventHeader>();
         foreach(var p in evt.GetType().GetProperties().Where(x=>x.Name.EndsWith("Id")))
         {
             var val = p.GetValue(evt,null);
             if (val==null)
                 continue;
             var hdr = new EventHeader{
                 Name = p.Name,
                 Value = val.ToString()
             };
             headers.Add(hdr);
         }
         adapter.SaveEvent(evtblob,headers);
     }
     return true;
 }