Пример #1
0
        /// <summary>
        /// Creates a new <see cref="Pipeline"/> from the provided definition.
        /// </summary>
        /// <param name="def">The <see cref="PipelineDefinition"/> describing
        /// the pipeline.</param>
        /// <returns>A <see cref="Pipeline"/> able to perform the processing described
        /// in the definition.</returns>
        public Pipeline CreatePipeline(PipelineDefinition def)
        {
            Pipeline p = new Pipeline();

            if (def == null)
            {
                return(p);
            }

            foreach (var definition in def)
            {
                PipelineEntry entry = _tryCreateEntry(definition);
                p.Add(entry);
            }

            return(p);
        }
Пример #2
0
        /// <summary>
        /// Attempts to create the plugin with the specified definition
        /// </summary>
        /// <param name="def">The definition provided by the client</param>
        /// <returns>The PipelineEntry represented by the definition,
        /// or null if an error occurs</returns>
        private PipelineEntry _tryCreateEntry(AlgorithmDefinition def)
        {
            PipelineEntry entry = null;

            try
            {
                AlgorithmPlugin p = _factory.Manufacture(def);
                if (p != null)
                {
                    entry = new PipelineEntry(p);
                    entry.ProcessInput = (ICloneable)def.ParameterObject.Clone();
                }
            }
            catch
            {
                // Todo logging
            }

            return(entry);
        }