/// <summary>
 /// Initializes a new instance of the <see cref="AsyncElasticsearchProjector"/> class.
 /// </summary>
 /// <param name="handlers">The handlers.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="handlers"/> is <c>null</c>.</exception>
 public AsyncElasticsearchProjector(ElasticsearchProjectionHandler[] handlers)
 {
     if (handlers == null) throw new ArgumentNullException("handlers");
     _handlers = handlers.
         GroupBy(handler => handler.Message).
         ToDictionary(@group => @group.Key, @group => @group.ToArray());
 }
        /// <summary>
        ///     Concatenates the handlers of this projection with the specified projection handler.
        /// </summary>
        /// <param name="handler">The projection handler to concatenate.</param>
        /// <returns>A <see cref="ElasticsearchProjection"/> containing the concatenated handlers.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="handler"/> is <c>null</c>.</exception>
        public ElasticsearchProjection Concat(ElasticsearchProjectionHandler handler)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");

            var concatenated = new ElasticsearchProjectionHandler[Handlers.Length + 1];
            Handlers.CopyTo(concatenated, 0);
            concatenated[Handlers.Length] = handler;
            return new ElasticsearchProjection(concatenated);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ElasticsearchProjection" /> class.
 /// </summary>
 /// <param name="handlers">The handlers.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="handlers" /> are <c>null</c>.</exception>
 public ElasticsearchProjection(ElasticsearchProjectionHandler[] handlers)
 {
     if (handlers == null) throw new ArgumentNullException("handlers");
     _handlers = handlers;
 }
        /// <summary>
        ///     Concatenates the handlers of this projection with the specified projection handlers.
        /// </summary>
        /// <param name="handlers">The projection handlers to concatenate.</param>
        /// <returns>A <see cref="ElasticsearchProjection"/> containing the concatenated handlers.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="handlers"/> are <c>null</c>.</exception>
        public ElasticsearchProjection Concat(ElasticsearchProjectionHandler[] handlers)
        {
            if (handlers == null)
                throw new ArgumentNullException("handlers");

            var concatenated = new ElasticsearchProjectionHandler[Handlers.Length + handlers.Length];
            Handlers.CopyTo(concatenated, 0);
            handlers.CopyTo(concatenated, Handlers.Length);
            return new ElasticsearchProjection(concatenated);
        }