Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of <see cref="RavenChildProjector{TProjection}"/>.
 /// </summary>
 /// <param name="mapBuilder">
 /// The <see cref="IEventMapBuilder{TProjection,TKey,TContext}"/>
 /// with already configured handlers for all the required events
 /// but not yet configured how to handle custom actions, projection creation, updating and deletion.
 /// The <see cref="IEventMap{TContext}"/> will be created from it.
 /// </param>
 /// <param name="setIdentity">
 /// Is used by the projector to set the identity of the projection.
 /// </param>
 /// <param name="children">An optional collection of <see cref="IRavenChildProjector"/> which project events
 /// in the same session just before the parent projector.</param>
 public RavenChildProjector(
     IEventMapBuilder <TProjection, string, RavenProjectionContext> mapBuilder,
     Action <TProjection, string> setIdentity,
     IEnumerable <IRavenChildProjector> children = null)
 {
     mapConfigurator = new RavenEventMapConfigurator <TProjection>(mapBuilder, setIdentity, children);
 }
        /// <summary>
        /// Creates a new instance of <see cref="RavenProjector{TProjection}"/>.
        /// </summary>
        /// <param name="sessionFactory">The delegate that creates a new <see cref="IAsyncDocumentSession"/>.</param>
        /// <param name="mapBuilder">
        /// The <see cref="IEventMapBuilder{TProjection,TKey,TContext}"/>
        /// with already configured handlers for all the required events
        /// but not yet configured how to handle custom actions, projection creation, updating and deletion.
        /// The <see cref="IEventMap{TContext}"/> will be created from it.
        /// </param>
        /// <param name="setIdentity">
        /// Is used by the projector to set the identity of the projection.
        /// </param>
        /// <param name="children">An optional collection of <see cref="IRavenChildProjector"/> which project events
        /// in the same session just before the parent projector.</param>
        public RavenProjector(
            Func <IAsyncDocumentSession> sessionFactory,
            IEventMapBuilder <TProjection, string, RavenProjectionContext> mapBuilder,
            Action <TProjection, string> setIdentity,
            IEnumerable <IRavenChildProjector> children = null)
        {
            if (mapBuilder == null)
            {
                throw new ArgumentNullException(nameof(mapBuilder));
            }

            this.sessionFactory = sessionFactory ?? throw new ArgumentNullException(nameof(sessionFactory));
            mapConfigurator     = new RavenEventMapConfigurator <TProjection>(mapBuilder, setIdentity, children);
        }