コード例 #1
0
ファイル: ServerBus.cs プロジェクト: JazzCF/BA_CF
        public void AddMatch(string rule)
        {
            MatchRule r = MatchRule.Parse(rule);

            if (r == null)
            {
                throw new Exception("r == null");
            }

            if (!Rules.ContainsKey(r))
            {
                Rules[r] = new List <Connection> ();
            }

            // Each occurrence of a Connection in the list represents one value-unique AddMatch call
            Rules[r].Add(Caller);

            Console.WriteLine("Added. Rules count: " + Rules.Count);
        }
コード例 #2
0
ファイル: ServerBus.cs プロジェクト: JazzCF/BA_CF
        public void RemoveMatch(string rule)
        {
            MatchRule r = MatchRule.Parse(rule);

            if (r == null)
            {
                throw new Exception("r == null");
            }

            if (!Rules.ContainsKey(r))
            {
                throw new Exception();
            }

            // We remove precisely one occurrence of the calling connection
            Rules[r].Remove(Caller);
            if (Rules[r].Count == 0)
            {
                Rules.Remove(r);
            }

            Console.WriteLine("Removed. Rules count: " + Rules.Count);
        }