Exemple #1
0
        public EventData Serialize(IEvent @event)
        {
            SerializeEventData(@event);

            var eventData = new EventData(
                Guid.NewGuid(),
                @event.GetType().FullName,
                true,
                SerializeEventData(@event),
                SerializeEventMetadata(@event));

            return(eventData);

            byte[] SerializeEventData(IEvent eventToSerialize)
            {
                var eventJson = JsonConvert.SerializeObject(eventToSerialize);

                return(Encoding.ASCII.GetBytes(eventJson));
            }

            byte[] SerializeEventMetadata(IEvent eventToSerialize)
            {
                var metadata = new EventMetadata(eventToSerialize);

                return(Encoding.ASCII.GetBytes(metadata.ToJson()));
            }
        }