예제 #1
0
        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());
     }
 }
예제 #3
0
 protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e)
 {
     if (e is JustAnEvent)
     {
         yield return "yay";
     }
     else
     {
         throw new ApplicationException("oh noes!!!!");
     }
 }
예제 #4
0
 /// <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 };
        }
예제 #6
0
        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);
            }
        }
예제 #8
0
 public void RegisterTimeSpent(IViewManager viewManager, DomainEvent domainEvent, TimeSpan duration)
 {
 }
예제 #9
0
 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]};
 }
예제 #11
0
 /// <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);
 }
예제 #12
0
 protected override IEnumerable<string> GetViewIds(IViewContext context, DomainEvent e)
 {
     return ViewInstanceIds;
 }
 public EventData Serialize(DomainEvent e)
 {
     return _innerDomainEventSerializer.Serialize(e);
 }