Exemple #1
0
        private void MarkRule_GenerateAllMarksHandler(object sender, MarkRuleEventArgs e)
        {
            var path = e.GetRulesPath();

            if (_marks.ContainsKey(path) == false)
            {
                _marks.Add(path, ActionsDescription.TryParse("", ""));
            }
        }
Exemple #2
0
        private void AddMark(Dictionary <string, ActionsDescription> marks, string mark)
        {
            string markpath, description;
            int    x = mark.IndexOf("->");

            if (x < 0)
            {
                markpath    = mark;
                description = "";
            }
            else
            {
                markpath    = mark.Substring(0, x).Trim();
                description = mark.Substring(x + 2).Trim();
            }

            ActionsDescription.Action[] extraActions = null;
            if (marks.ContainsKey(markpath))
            {
                Console.WriteLine("Warning: Duplicated mark {0}", markpath);
                extraActions = marks[markpath].Actions;
                marks.Remove(markpath);
            }

            var xmark = ActionsDescription.TryParse(description, markpath, extraActions);

            if (xmark == null)
            {
                throw new Exception(string.Format("Error: Failed to parse mark {0}", markpath));
            }
            else
            {
                if (xmark.Actions == null || xmark.Actions[0].Mark != Marks.Group)
                {
                    marks.Add(markpath, xmark);
                }
                else
                {
                    try
                    {
                        var group = _groups[xmark.Actions[0].Args[1]];

                        foreach (var item in group)
                        {
                            marks.Add(markpath + item.Key, item.Value.Clone("?", xmark.Actions[0].Args[0]));
                        }
                    }
                    catch (KeyNotFoundException)
                    {
                        Console.WriteLine("Group not defined {0}", xmark.Actions[0].Args[0]);
                        throw new Exception();
                    }
                }
            }
        }