private static PipeOutputPackage SimplifyOutput(PipeOutputPackage package)
        {
            Type newOutputType = DetermineNewInterestType(package.OutputType);

            return(newOutputType == package.OutputType
                ? package
                : PipeOutputPackage.Direct(package.InputType, newOutputType, package.ProcessInput));
        }
        private static PipeOutputPackage SimplifyInput(PipeOutputPackage package)
        {
            Type newInputType = DetermineNewInterestType(package.InputType);

            if (newInputType == package.InputType)
            {
                return(package);
            }

            PipeCallback processCallbackFunc = (input, broker) =>
            {
                Func <object, object> transformFunc =
                    TransformerFactory.ConvertFor(newInputType, package.InputType);
                object revisedInput = transformFunc(input);
                return(package.ProcessInput(revisedInput, broker));
            };

            return(PipeOutputPackage.Direct(newInputType, package.OutputType, processCallbackFunc));
        }