Example #1
0
        public override void Visit(VisitArgs args)
        {
            TRef value = default(TRef);
            TKey key   = default(TKey);

            var old = args.Match;

            var matches    = args.Match.Matches;
            var matchCount = matches.Count;

            for (int i = 0; i < matchCount; i++)
            {
                var match = args.Match = matches[i];
                args.ResetChild();
                if (namedKey && match.Name == keyName)
                {
                    KeyBuilder.Visit(args);
                    key = (TKey)args.Child;
                    continue;
                }

                if (namedValue && match.Name == valueName)
                {
                    ValueBuilder.Visit(args);
                    value = (TRef)args.Child;
                    continue;
                }
                if (!namedKey)
                {
                    KeyBuilder.Visit(args);
                    if (args.ChildSet)
                    {
                        key = (TKey)args.Child;
                        continue;
                    }
                }
                if (!namedValue)
                {
                    ValueBuilder.Visit(args);
                    if (args.ChildSet)
                    {
                        value = (TRef)args.Child;
                        continue;
                    }
                }
            }

            Add((T)args.Instance, key, value);
            args.Match = old;
        }