Ejemplo n.º 1
0
        public NameInfo Lookup(ErrorCollector collector, IEnumerable <string> names)
        {
            IEnumerator <string> enumerator = names.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                throw new ArgumentOutOfRangeException("List of names cannot be empty.");
            }
            if (Children.ContainsKey(enumerator.Current))
            {
                if (Children[enumerator.Current] == null)
                {
                    collector.ReportForbiddenNameAccess(this, enumerator.Current);
                    return(new JunkInfo());
                }
                return(Children[enumerator.Current].Lookup(collector, enumerator));
            }
            if (ForceBack)
            {
                Parent.Lookup(collector, names);
            }
            if (Parent != null && Parent.HasName(enumerator.Current))
            {
                return(Lookback(enumerator.Current).Lookup(collector, enumerator));
            }
            var info = new OpenNameInfo(this, enumerator.Current);

            Children[enumerator.Current] = info;
            return(info.Lookup(collector, enumerator));
        }