Beispiel #1
0
        public override void Visit(VisitArgs args)
        {
            var           oldMatch = args.Match;
            IList <Match> matches;

            if (Name != null)
            {
                matches = args.Match.Find(Name).ToList();
            }
            else
            {
                matches = args.Match.Matches;
            }

            for (int i = 0; i < matches.Count; i++)
            {
                Match match = matches[i];
                args.Match = match;
                args.ResetChild();
                base.Visit(args);
                if (args.ChildSet)
                {
                    Add((T)args.Instance, (TRef)args.Child);
                }
            }
            args.Match = oldMatch;
        }
Beispiel #2
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;
        }