Exemplo n.º 1
0
        static void CheckSerializedPipeline(SerializedPipeline pipeline)
        {
            // condition stages != null && stageConnections != null
            if (pipeline == null || pipeline.stages == null || pipeline.stageConnections == null)
            {
                throw new Exception("Cannot create pipeline: pipeline, stages, or stageConnections was null");
            }

            // condition: all stages.stageKey != null
            if (pipeline.stages.Select((x) => x.stageKey).Any((x) => string.IsNullOrEmpty(x)))
            {
                throw new Exception("Cannot create pipeline: stages.stageKey was null or empty");
            }

            // condition: all stages.className != null
            if (pipeline.stages.Select((x) => x.stageClass).Any((x) => string.IsNullOrEmpty(x)))
            {
                throw new Exception("Cannot create pipeline: stages.stageClass was null or empty");
            }

            // condition: all stages.arguments != null
            if (pipeline.stages.Select((x) => x.arguments).Any((x) => x == null))
            {
                throw new Exception("Cannot create pipeline: stages.arguments was null");
            }

            // condition: All keys in pipeline.stages should be unique
            if (pipeline.stages.Select((x) => x.stageKey).Distinct().Count() != pipeline.stages.Length)
            {
                throw new Exception("Cannot create pipeline: stages.stageKey are not unique");
            }

            // condition: all stageConnections.stageKey != null
            if (pipeline.stageConnections.Select((x) => x.stageKey).Any((x) => string.IsNullOrEmpty(x)))
            {
                throw new Exception("Cannot create pipeline: stageConnections.stageKey was null or empty");
            }

            // condition: all stageConnections.outputs != null
            if (pipeline.stageConnections.Select((x) => x.outputs).Any((x) => x == null))
            {
                throw new Exception("Cannot create pipeline: stageConnections.outputs was null");
            }

            // condition: All keys in stageConnections should be unique
            if (pipeline.stageConnections.Select((x) => x.stageKey).Distinct().Count() != pipeline.stageConnections.Length)
            {
                throw new Exception("Cannot create pipeline: stages.stageKey are not unique");
            }

            // condition: all stageKeys in stageConnections exist in stages
            // checked in ConnectPipeables by stages dictionary?

            // condition: all stages are used by at least one stageConnection
            // TODO warning maybe?
        }
Exemplo n.º 2
0
        static Dictionary <string, IPipeable> CreateFromSerialized(SerializedPipeline pipeline, Dictionary <string, object> scope)
        {
            var allStages = new Dictionary <string, IPipeable>();

            foreach (var stage in pipeline.stages)
            {
                allStages.Add(stage.stageKey, CreatePipeableInstance(stage, scope));
            }
            return(allStages);
        }