本文整理汇总了C#中EventStore.ClientAPI.ResolvedEvent类的典型用法代码示例。如果您正苦于以下问题:C# ResolvedEvent类的具体用法?C# ResolvedEvent怎么用?C# ResolvedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolvedEvent类属于EventStore.ClientAPI命名空间,在下文中一共展示了ResolvedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GotEvent
private void GotEvent(EventStoreCatchUpSubscription sub, ResolvedEvent evt)
{
try
{
//create local copies of state variables
var total = _total;
var checkpoint = evt.Event.EventNumber;
var amount = (string)JObject.Parse(Encoding.UTF8.GetString(evt.Event.Data))["amount"];
switch (evt.Event.EventType.ToUpperInvariant())
{
case "CREDIT":
total += int.Parse(amount);
break;
case "DEBIT":
total -= int.Parse(amount);
break;
default:
throw new Exception("Unknown Event Type");
}
File.WriteAllText(_localFile, checkpoint + "," + total);
//Update the common state after commit to disk
_total = total;
Checkpoint = checkpoint;
}
catch (Exception ex)
{
_view.ErrorMsg = "Event Exception: " + ex.Message;
}
//repaint screen
_view.Total = _total;
}
示例2: StreamEventsSlice
internal StreamEventsSlice(SliceReadStatus status,
string stream,
int fromEventNumber,
ReadDirection readDirection,
ClientMessage.ResolvedIndexedEvent[] events,
int nextEventNumber,
int lastEventNumber,
bool isEndOfStream)
{
Ensure.NotNullOrEmpty(stream, "stream");
Status = status;
Stream = stream;
FromEventNumber = fromEventNumber;
ReadDirection = readDirection;
if (events == null || events.Length == 0)
Events = Empty.ResolvedEvents;
else
{
Events = new ResolvedEvent[events.Length];
for (int i = 0; i < Events.Length; ++i)
{
Events[i] = new ResolvedEvent(events[i]);
}
}
NextEventNumber = nextEventNumber;
LastEventNumber = lastEventNumber;
IsEndOfStream = isEndOfStream;
}
示例3: EventAppeared
void EventAppeared(EventStoreCatchUpSubscription sub, ResolvedEvent evnt)
{
if (evnt.OriginalStreamId.StartsWith("$"))
return;
dynamic ev = _adapter.TryGetDomainEvent(evnt);
if (ev == null)
return;
try
{
lock (this)
{
Dispatch(ev);
_succeded++;
_checkPoint = evnt.OriginalPosition.GetValueOrDefault();
_lastEventNumber = evnt.OriginalEventNumber;
if(ev.Timestamp > LastUpdate)
LastUpdate = ev.Timestamp;
}
}
catch (Exception)
{
Debugger.Break();
}
}
示例4: EventAppeared
private static void EventAppeared(EventStorePersistentSubscriptionBase eventStorePersistentSubscriptionBase,
ResolvedEvent resolvedEvent)
{
;
var data = Encoding.ASCII.GetString(resolvedEvent.Event.Data);
Console.WriteLine("Received: " + resolvedEvent.Event.EventStreamId + ":" + resolvedEvent.Event.EventNumber);
Console.WriteLine(data);
}
示例5: CommandResponseReceived
private void CommandResponseReceived(EventStoreSubscription subscription, ResolvedEvent resolvedEvent)
{
if (ResponseReceived == null) return;
var response = resolvedEvent.ParseJson<CommandResponse>();
ResponseReceived(this, new CommandResponseEventArgs(response));
}
示例6: ProcessEvent
private void ProcessEvent(EventStoreCatchUpSubscription subscribtion, ResolvedEvent resolvedEvent)
{
var alarm = resolvedEvent.ParseJson<IrresponsibleGamblerDetected>();
Publish(alarm);
StoreCheckpoint(resolvedEvent);
}
示例7: DeserializeEventData
public static object DeserializeEventData(
this ISerializer serializer,
ResolvedEvent resolvedEvent)
{
IDictionary<string, object> _;
return serializer.DeserializeEventData(resolvedEvent, out _);
}
示例8: GetDomainEvent
dynamic GetDomainEvent(ResolvedEvent evnt)
{
var metadata = evnt.Event.Metadata;
var data = evnt.Event.Data;
var jmeta = JObject.Parse(Encoding.UTF8.GetString(metadata));
var eventClrTypeName = jmeta.Property(EventClrTypeHeader).Value;
dynamic ev = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data), Type.GetType((string)eventClrTypeName));
return ev;
}
示例9: EventAppeard
private void EventAppeard(EventStoreSubscription subscription, ResolvedEvent @event)
{
var representation = _deserializer.GetRepresentation(_serializer, @event.OriginalEvent);
var payload = representation.Payload;
if (payload != null)
{
_self.Tell(payload);
}
}
示例10: HandleNewEvent
private void HandleNewEvent(EventStoreCatchUpSubscription subscription, ResolvedEvent @event)
{
// make sure the event fits the ones this handler cares about
if (!_eventFilter(@event)) { return; }
var _event = ProcessRawEvent(@event);
// filter for null event ( didn't have metadata or data )
if (_event == null) { return; }
HandleEvent(_event);
}
示例11: TryGetDomainEvent
public dynamic TryGetDomainEvent(ResolvedEvent evnt)
{
try
{
return GetDomainEvent(evnt);
}
catch
{
return null;
}
}
示例12: Deserialize
public IEnumerable<object> Deserialize(ResolvedEvent resolvedEvent)
{
var type = Type.GetType(resolvedEvent.Event.EventType + ", UserService.DomainModel", true);
using (var stream = new MemoryStream(resolvedEvent.Event.Data))
{
using (var reader = new StreamReader(stream))
{
yield return JsonSerializer.CreateDefault().Deserialize(reader, type);
}
}
}
示例13: MapToFeedItem
private SyndicationItem MapToFeedItem(ResolvedEvent ev)
{
return new SyndicationItem(
"BeganFollowingEvent",
Encoding.UTF8.GetString(ev.Event.Data),
new Uri(RequestContext.Url.Content("/beganfollowing/" +
ev.Event.EventId)),
ev.Event.EventId.ToString(),
DateTime.Now // Event store client does not return timestamp yet
);
}
示例14: OnEventReceived
protected override void OnEventReceived(ResolvedEvent resolvedEvent)
{
switch (resolvedEvent.OriginalEvent.EventType)
{
case UserEventType.UserCreated:
AddAccount(resolvedEvent.OriginalEvent);
break;
case ContactEventType.AccountContactRefreshRequest:
ProcessRefreshRequest(resolvedEvent.OriginalEvent);
break;
}
}
示例15: Map
private static EventEnvelope Map(ResolvedEvent resolvedEvent)
{
var bytesAsString = Encoding.UTF8.GetString(resolvedEvent.Event.Data);
var a = JsonConvert.DeserializeObject(bytesAsString) as IEvent;
var jsonMetadata = Encoding.UTF8.GetString(resolvedEvent.Event.Metadata);
var metadata = JsonConvert.DeserializeObject<EventMetadata>(jsonMetadata);
var typeName = Type.GetType(metadata.Type);
var @event = (IEvent)JsonConvert.DeserializeObject(bytesAsString, typeName);
var envelope = new EventEnvelope(@event, metadata);
return envelope;
}