コード例 #1
0
        /// <summary>
        /// Finishes configuring a projection creation or updating handler for events of type <typeparamref name="TEvent"/>
        /// for projections of type <typeparamref name="TProjection"/> using context of type <typeparamref name="TContext"/>.
        /// </summary>
        /// <param name="eventActionBuilder">
        /// The <see cref="ICreateOrUpdateEventActionBuilder{TEvent,TProjection,TContext}"/>.
        /// </param>
        /// <param name="projector">
        /// The asynchronous delegate that initializes the created projection or updates the existing projection.
        /// Takes the projection and the event as the parameters.
        /// </param>
        public static void Using <TEvent, TProjection, TContext>(
            this ICreateOrUpdateEventActionBuilder <TEvent, TProjection, TContext> eventActionBuilder,
            Func <TProjection, TEvent, Task> projector)
        {
            if (eventActionBuilder == null)
            {
                throw new ArgumentNullException(nameof(eventActionBuilder));
            }

            if (projector == null)
            {
                throw new ArgumentNullException(nameof(projector));
            }

            eventActionBuilder.Using((projection, anEvent, context) => projector(projection, anEvent));
        }
コード例 #2
0
        /// <summary>
        /// Finishes configuring a projection creation or updating handler for events of type <typeparamref name="TEvent"/>
        /// for projections of type <typeparamref name="TProjection"/> using context of type <typeparamref name="TContext"/>.
        /// </summary>
        /// <param name="eventActionBuilder">
        /// The <see cref="ICreateOrUpdateEventActionBuilder{TEvent,TProjection,TContext}"/>.
        /// </param>
        /// <param name="projector">
        /// The synchronous delegate that initializes the created projection or updates the existing projection.
        /// Takes the projection and the event as the parameters.
        /// </param>
        public static void Using <TEvent, TProjection, TContext>(
            this ICreateOrUpdateEventActionBuilder <TEvent, TProjection, TContext> eventActionBuilder,
            Action <TProjection, TEvent> projector)
        {
            if (eventActionBuilder == null)
            {
                throw new ArgumentNullException(nameof(eventActionBuilder));
            }

            if (projector == null)
            {
                throw new ArgumentNullException(nameof(projector));
            }

            eventActionBuilder.Using((projection, anEvent, context) =>
            {
                projector(projection, anEvent);
                return(SpecializedTasks.FalseTask);
            });
        }