Пример #1
0
 public void Add(HandlerPlan hp)
 {
     if (!_data.ContainsKey(hp.ReactOn))
     {
         _data[hp.ReactOn] = new HandlerCollection();
     }
     _data[hp.ReactOn].AddGuardAndRecipe(hp);
 }
Пример #2
0
        public void AddGuardAndRecipe(HandlerPlan hp)
        {
            for (int i = 0; i < _triggers.Count; i++)
            {
                if (_triggers[i] == hp.GuardFlag && _reacts[i].Value == hp.ReactOn.Value)
                {
                    hp.AddRecipeTo(Handlers[i]);
                    return;
                }
            }

            // if branch not found, make a new one
            _reacts.Add(hp.ReactOn);
            _triggers.Add(hp.GuardFlag);
            hp.AddRecipeTo(Handlers);
        }
Пример #3
0
        internal void AddHandler(HandlerPlan hp)
        {
            string type = hp.ReactOn.Value;

            foreach (var k in Tokens.Keys)
            {
                if (Tokens[k].Contains(hp.ReactOn))
                {
                    type = k;
                }
            }
            if (String.IsNullOrEmpty(type))
            {
                Console.WriteLine($"[A2B] Cannot determine type of token '{hp.ReactOn.Value}'");
            }
            if (!Handlers.ContainsKey(type))
            {
                Handlers[type] = new List <B.HandlerPlan>();
            }
            Handlers[type].Add(hp);
        }