public virtual StandardReturType BaseValidate <TOutput>(MethodHeader header, TInputElement[] input)
        {
            // Initialize context
            try
            {
                BrokerContext.Initialize(header.ApplicationToken, header.UserToken);
            }
            catch (Exception ex)
            {
                return(StandardReturType.InvalidApplicationToken(header.ApplicationToken));
            }

            // Validate input
            if (input == null || input.Length == 0)
            {
                return(StandardReturType.NullInput());
            }

            var ret = Validate(input);

            if (ret == null)
            {
                ret = StandardReturType.UnspecifiedError("Validation failed");
            }

            return(ret);
        }
        /// <summary>
        /// Gets result for a single input element.
        /// It is basically a wrapper for the more general array version GetBatch<>()
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <typeparam name="TBatchOutput"></typeparam>
        /// <param name="header"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public TOutput GetSingle <TOutput, TBatchOutput>(MethodHeader header, TInputElement input)
            where TOutput : IBasicOutput <TOutputElement>, new()
            where TBatchOutput : IBasicOutput <TOutputElement[]>, new()
        {
            var batchRet = GetBatch <TBatchOutput>(header, new TInputElement[] { input });

            return(new TOutput()
            {
                StandardRetur = batchRet.StandardRetur,
                Item = batchRet.Item.Length == 1 ? batchRet.Item[0] : default(TOutputElement)
            });
        }
        /// <summary>
        /// Gets the result for an array of input items
        /// </summary>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="header">Header tokens</param>
        /// <param name="input">Array of input items</param>
        /// <returns>Composite result for the operation</returns>
        public TOutput GetBatch <TOutput>(MethodHeader header, TInputElement[] input)
            where TOutput : IBasicOutput <TOutputElement[]>, new()
        {
            try
            {
                // Validate
                var ret = BaseValidate <TOutput>(header, input);

                if (!StandardReturType.IsSucceeded(ret))
                {
                    return new TOutput()
                           {
                               StandardRetur = ret
                           }
                }
                ;

                // Data providers
                IEnumerable <TInterface> dataProviders;
                // TODO: Create an execution plan here
                var providerMethod = new ProviderMethod <TInputElement, TOutputElement, Element, object, TInterface>();

                ret = CreateDataProviders(providerMethod, out dataProviders);

                if (!StandardReturType.IsSucceeded(ret))
                {
                    return new TOutput()
                           {
                               StandardRetur = ret
                           }
                }
                ;

                // Call data providers
                var allElements = providerMethod.CallDataProviders(dataProviders, input);

                // Aggregate
                return(Aggregate <TOutput>(allElements));
            }
            catch (Exception ex)
            {
                Local.Admin.LogException(ex);
                return(new TOutput()
                {
                    StandardRetur = StandardReturType.UnspecifiedError()
                });
            }
        }