示例#1
0
        public bool IsAllowable(Pipeline pipeline)
        {
            // Pipeline is not compatible with the execution context of the pipeline use case
            if (!_context.IsAllowable(pipeline))
            {
                return(false);
            }
            try
            {
                // Does the pipeline contain any components that are invalid under the current list of available initialization objects etc
                foreach (var component in pipeline.PipelineComponents)
                {
                    var type = component.GetClassAsSystemType();
                    if (type == null)
                    {
                        return(false);
                    }

                    var advert = new AdvertisedPipelineComponentTypeUnderContext(type, this);
                    if (!advert.IsCompatible())
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                // if any Pipeline components are broken e.g. not possible to find the Type they reference
                // then we tell the user it is not compatible
                return(false);
            }

            // nothing incompatible here
            return(true);
        }
        /// <inheritdoc/>
        public IDataFlowPipelineEngine Create(IPipeline pipeline, IDataLoadEventListener listener)
        {
            string reason;

            if (!_context.IsAllowable(pipeline, out reason))
            {
                throw new Exception("Cannot create pipeline because: " + reason);
            }

            var destination = GetBest(_useCase.ExplicitDestination, CreateDestinationIfExists(pipeline), "destination");
            var source      = GetBest(_useCase.ExplicitSource, CreateSourceIfExists(pipeline), "source");


            //new DataFlowPipelineEngine<T>(_context, source, destination, listener, pipeline);

            //engine (this is the source, target is the destination)
            var dataFlowEngine = (IDataFlowPipelineEngine)_constructor.ConstructIfPossible(_engineType, _context, source, destination, listener, pipeline);

            //now go fetch everything that the user has configured for this particular pipeline
            foreach (PipelineComponent toBuild in pipeline.PipelineComponents)
            {
                //if it is the destination do not add it
                if (toBuild.ID == pipeline.DestinationPipelineComponent_ID)
                {
                    continue;
                }

                //if it is the source do not add it
                if (toBuild.ID == pipeline.SourcePipelineComponent_ID)
                {
                    continue;
                }

                //get the factory to realize the freaky Export types defined in any assembly anywhere and set their DemandsInitialization properties based on the Arguments
                object component = CreateComponent(toBuild);

                //Add the components to the pipeline
                dataFlowEngine.ComponentObjects.Add(component);
            }

            return(dataFlowEngine);
        }