本文整理汇总了C#中IEvent.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# IEvent.ToJson方法的具体用法?C# IEvent.ToJson怎么用?C# IEvent.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent.ToJson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventBusMessage
/// <summary>
/// Initialize a new EventBusMessage from an event instance
/// </summary>
/// <param name="eventInstance">Event Instance</param>
public EventBusMessage(IEvent eventInstance)
{
// Validate Arguments
if (eventInstance == null)
throw new ArgumentNullException(nameof(eventInstance));
// Build instance
EventType = eventInstance.GetType().Name;
EventJson = eventInstance.ToJson();
}
示例2: TraceEvent
private static void TraceEvent(IEvent e)
{
Trace.WriteLine(string.Format("{0}.{1}",
e.EventStreamName(),
e.EventName()));
Trace.WriteLine(
e.ToJson(Formatting.Indented)
.Split('\n')
.Select(line => " " + line)
.ToDelimitedString("\n"));
}
示例3: CreateEventHandlingError
private static EventHandlingError CreateEventHandlingError(IEvent e) =>
new EventHandlingError
{
Actor = e.Actor(),
AggregateId = e.AggregateId,
SequenceNumber = e.SequenceNumber,
SerializedEvent = e.ToJson(),
StreamName = e.EventStreamName(),
EventTypeName = e.EventName(),
OriginalId = null
};
示例4: Convert
private static PersistentEvent Convert(Type aggregatedRootType, Guid aggregateId, IEvent @event)
{
var eventType = @event.GetType();
var entity = new PersistentEvent(aggregateId)
{
AggregateId = aggregateId,
AggregatedRootType = aggregatedRootType.AssemblyQualifiedName,
EventType = eventType.AssemblyQualifiedName,
SerializedEvent = @event.ToJson(),
Name = eventType.Name,
Occured = SystemClock.GetCurrentTime(),
};
return entity;
}