public EventData Serialize(DomainEvent e) { var serializedObject = JsonConvert.SerializeObject(e, jsonSerializerSettings); var eventData = EventData.FromDomainEvent(e, Encoding.UTF8.GetBytes(serializedObject)); eventData.MarkAsJson(); return eventData; }
public EventData Serialize(DomainEvent e) { using (var result = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(result, e); return EventData.FromDomainEvent(e, result.GetBuffer()); } }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { if (e is JustAnEvent) { yield return "yay"; } else { throw new ApplicationException("oh noes!!!!"); } }
/// <summary> /// Applies the given event, performing any related lookups using the given unit of work /// </summary> public void Apply(DomainEvent domainEvent, IUnitOfWork unitOfWork) { var previousUnitOfWork = Instance.UnitOfWork; try { Instance.UnitOfWork = unitOfWork; Instance.ApplyEvent(domainEvent, ReplayState.ReplayApply); } finally { Instance.UnitOfWork = previousUnitOfWork; } }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { if (!(e is NodeAttachedToParentNode)) throw new ArgumentException(String.Format("Can't handle {0}", e)); var node = context.Load<Node>(e.GetAggregateRootId()); while (node.ParentNodeId != null) { node = context.Load<Node>(node.ParentNodeId); } return new[] { node.Id }; }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { var handlerMethod = _handlerMethodsByDomainEventType.GetOrAdd(e.GetType(), GetHandlerMethodFor); if (handlerMethod == null) return new string[0]; try { var ids = ((IEnumerable<string>)handlerMethod.Invoke(this, new object[] { context, e })).ToList(); return ids; } catch (Exception exception) { throw new ApplicationException(string.Format("Could not get IDs for domain event {0}!", e), exception); } }
public EventData Serialize(DomainEvent e) { try { var jsonText = JsonConvert.SerializeObject(e, Settings); var data = DefaultEncoding.GetBytes(jsonText); var result = EventData.FromDomainEvent(e, data); result.MarkAsJson(); return result; } catch (Exception exception) { throw new SerializationException(string.Format("Could not serialize DomainEvent {0} into JSON! (headers: {1})", e, e.Meta), exception); } }
public void RegisterTimeSpent(IViewManager viewManager, DomainEvent domainEvent, TimeSpan duration) { }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { return e.Meta.Keys.ToArray(); }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { return new[] {e.Meta[DomainEvent.MetadataKeys.AggregateRootId]}; }
/// <summary> /// Constructs an <see cref="EventData"/> that wraps the given <see cref="DomainEvent"/> and the raw serialized body of that event /// </summary> public static EventData FromDomainEvent(DomainEvent domainEvent, byte[] data) { return new EventData(data, domainEvent.Meta); }
protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e) { return ViewInstanceIds; }
public EventData Serialize(DomainEvent e) { return _innerDomainEventSerializer.Serialize(e); }