Esempio n. 1
0
        private List <BoltExcuter> CreateLevel(List <string> levelList, Dictionary <string, DependItem> dependList)
        {
            var excuteList = new List <BoltExcuter>();

            foreach (var item in levelList)
            {
                var boltInfo = dependList[item];
                var bolt     = (IBolt)Activator.CreateInstance(boltInfo.Type);

                if (bolt is BoltDelegate)
                {
                    ((BoltDelegate)bolt).SetAction(boltInfo.BoltAction);
                }

                IInputs inputs = null;
                if (boltInfo.Previous != null)
                {
                    inputs = new InputCollection(boltInfo.Previous, boltList);
                }
                else
                {
                    inputs = this.userInput;
                }

                var boltExcuter = new BoltExcuter(bolt, inputs);
                this.boltList.Add(item, boltExcuter);
                excuteList.Add(boltExcuter);
            }

            return(excuteList);
        }
Esempio n. 2
0
        public InputCollection(string[] previous, Dictionary <string, BoltExcuter> boltList)
        {
            this.outputList = new List <Output>();
            if (previous != null)
            {
                foreach (var item in previous)
                {
                    BoltExcuter boltExecuter = null;
                    if (!boltList.TryGetValue(item, out boltExecuter))
                    {
                        throw new Exception(string.Format("不存名为{0}的Bolt", item));
                    }

                    this.outputList.Add(boltList[item].output);
                }
            }
        }