Example #1
0
        public void ConfigureSourceProcessingStrategy(QuerySourceProcessingStrategyBuilder builder)
        {
            CheckDisposed();
            var sourcesDefintion = _query.GetSourcesDefintion();

            if (sourcesDefintion == null)
            {
                throw new InvalidOperationException("Invalid query.  No source definition.");
            }
            if (sourcesDefintion.AllStreams)
            {
                builder.FromAll();
            }
            else
            {
                if (sourcesDefintion.Streams != null)
                {
                    foreach (var stream in sourcesDefintion.Streams)
                    {
                        builder.FromStream(stream);
                    }
                }
                if (sourcesDefintion.Categories != null)
                {
                    foreach (var category in sourcesDefintion.Categories)
                    {
                        builder.FromCategory(category);
                    }
                }
            }
            if (sourcesDefintion.AllEvents)
            {
                builder.AllEvents();
            }
            else
            if (sourcesDefintion.Events != null)
            {
                foreach (var @event in sourcesDefintion.Events)
                {
                    builder.IncludeEvent(@event);
                }
            }
            if (sourcesDefintion.ByStreams)
            {
                builder.SetByStream();
            }
            if (!string.IsNullOrWhiteSpace(sourcesDefintion.Options.StateStreamName))
            {
                builder.SetStateStreamNameOption(sourcesDefintion.Options.StateStreamName);
            }
            if (!string.IsNullOrWhiteSpace(sourcesDefintion.Options.ForceProjectionName))
            {
                builder.SetForceProjectionName(sourcesDefintion.Options.ForceProjectionName);
            }
            if (sourcesDefintion.Options.UseEventIndexes)
            {
                builder.SetUseEventIndexes(true);
            }
        }