Beispiel #1
0
        /// <summary>
        /// Constructs a new <see cref="EventData"/> instance using given event properties
        /// and additional entity includes.
        /// </summary>
        /// <param name="id">
        /// The unique identifier of the event (used for duplicate event detection).
        /// </param>
        /// <param name="properties">
        /// The properties for this event (includes both meta and data properties).
        /// </param>
        /// <param name="includes">
        /// Additional entity includes to be stored along with this event
        ///  </param>
        public EventData(EventId id, EventProperties properties, EventIncludes includes)
        {
            Requires.NotNull(properties, "properties");
            Requires.NotNull(includes, "includes");

            Id = id;
            Includes = includes;
            Properties = properties;
        }
Beispiel #2
0
        static EventData CreateEvent(string id, params Include[] includes)
        {
            var properties = new Dictionary <string, EntityProperty>
            {
                { "Id", new EntityProperty(id) },
                { "Type", new EntityProperty("StreamChanged") },
                { "Data", new EntityProperty("{}") }
            };

            return(new EventData(
                       EventId.From(id),
                       EventProperties.From(properties),
                       EventIncludes.From(includes)));
        }
        static EventData Event(object @event, params Include[] includes)
        {
            var id = Guid.NewGuid();

            var properties = new
            {
                Type = @event.GetType().Name,
                Data = JsonConvert.SerializeObject(@event)
            };

            return(new EventData(
                       EventId.From(id),
                       EventProperties.From(properties),
                       EventIncludes.From(includes)));
        }
Beispiel #4
0
        public void When_single_event_along_with_includes_is_over_WATS_max_batch_size_limit()
        {
            var stream = new Stream(partition);

            var includes = Enumerable
                           .Range(1, Api.AzureMaxBatchSize)
                           .Select(i => Include.Insert(new TestEntity(i.ToString())))
                           .ToArray();

            var @event = new EventData(
                EventId.From("offsize"),
                EventIncludes.From(includes)
                );

            Assert.ThrowsAsync <InvalidOperationException>(
                async() => await Stream.WriteAsync(stream, @event));
        }
        public static EventData ToEventData(this DomainEvent e, int version, params ITableEntity[] includes)
        {
            // Properties are turned into columns in the table, which can be
            // convenient for quickly glancing at the data.
            var properties = new
            {
                // Visualizing the event id in the table as a column is useful for querying
                e.EventId,
                EventType   = e.GetType().FullName,
                Data        = new Serializer().Serialize(e),
                DataVersion = (e.GetType().Assembly.GetName().Version ?? new Version(1, 0)).ToString(2),
                Version     = version,
            };

            return(new EventData(
                       // This turns off the SS-UID-[id] duplicate event detection rows, since
                       // we use GUIDs for events and therefore we'll never be duplicating
                       EventId.None,
                       EventProperties.From(properties),
                       EventIncludes.From(includes.Select(x => Include.InsertOrReplace(x)))));
        }
Beispiel #6
0
 static EventData CreateEvent(params Include[] includes)
 {
     return(new EventData(EventId.None, EventProperties.None, EventIncludes.From(includes)));
 }
Beispiel #7
0
 static EventData Event(params Include[] includes)
 {
     return(new EventData(EventId.None, EventIncludes.From(includes)));
 }
Beispiel #8
0
 /// <summary>
 /// Constructs a new <see cref="EventData"/> instance which doesn't have any additional properties 
 /// but includes a set of additional entity includes.
 /// </summary>
 /// <param name="id">
 /// The unique identifier of the event (used for duplicate event detection).
 /// </param>
 /// <param name="includes">
 /// Additional entity includes to be stored along with this event
 ///  </param>
 public EventData(EventId id, EventIncludes includes)
     : this(id, EventProperties.None, includes)
 {
 }