コード例 #1
0
        public static EventStoreProjection BuildProjectionDefinition(EventStoreProjectionParameters parameters)
        {
            var body = $"fromStreams({CreateSourceStreams(parameters.SourceStreamNames)}).when({{{CreateBody(parameters)}}})";

            return(new EventStoreProjection {
                Name = parameters.Name, Source = body
            });
        }
コード例 #2
0
        static string CreateBody(EventStoreProjectionParameters parameters)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < parameters.EventsToInclude.Length; i++)
            {
                if (IsNotFirstElement(i))
                {
                    sb.Append(",");
                }
                sb.Append($"{parameters.EventsToInclude[i].Name}: function(s,e){{linkTo('{parameters.DestinationStreamName}', e);return s;}}");
            }
            return(sb.ToString());
        }