/// <summary>
        /// Register an aggregate projection that should be evaluated inline
        /// </summary>
        /// <param name="projection"></param>
        /// <typeparam name="T"></typeparam>
        /// <param name="lifecycle">Optionally override the ProjectionLifecycle</param>
        /// <returns>The extended storage configuration for document T</returns>
        public void Add <T>(AggregateProjection <T> projection, ProjectionLifecycle?lifecycle = null)
        {
            if (lifecycle.HasValue)
            {
                projection.Lifecycle = lifecycle.Value;
            }

            projection.CompileAndAssertValidity();

            All.Add(projection);
        }
        public void adding_filter_for_another_aggregate_type()
        {
            var projection = new AggregateProjection <MyAggregate>();

            projection.ProjectEvent <AEvent>(a => { });
            projection.FilterIncomingEventsOnStreamType(typeof(OtherAggregate));
            projection.CompileAndAssertValidity();

            using var store = DocumentStore.For(ConnectionSource.ConnectionString);
            var filters = projection.BuildFilters(store);

            var filter = filters.OfType <AggregateTypeFilter>().Single();

            filter.AggregateType.ShouldBe(typeof(OtherAggregate));
        }
        /// <summary>
        /// Use a "self-aggregating" aggregate of type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="lifecycle">Override the aggregate lifecycle. The default is Inline</param>
        /// <returns>The extended storage configuration for document T</returns>
        public MartenRegistry.DocumentMappingExpression <T> SelfAggregate <T>(ProjectionLifecycle?lifecycle = null)
        {
            // Make sure there's a DocumentMapping for the aggregate
            var expression = _options.Schema.For <T>();

            var source = new AggregateProjection <T>()
            {
                Lifecycle = lifecycle ?? ProjectionLifecycle.Inline
            };

            source.CompileAndAssertValidity();
            All.Add(source);

            return(expression);
        }