Ejemplo n.º 1
0
        /// <summary>
        /// Inserts a series of new <see cref="ITypedLocalMember"/> instances
        /// with the <see cref="TypedNameSeries"/>, relative to the active
        /// scope, for the <see cref="ITypedLocalMember"/> elements to add.
        /// </summary>
        /// <param name="namesAndTypes">The <see cref="TypedNameSeries"/>
        /// which denotes each element's name and type within the active scope.</param>
        /// <returns>a series of new <see cref="ITypedLocalMember"/> instances
        /// with the <see cref="TypedNameSeries"/> provided.</returns>
        public ITypedLocalMember[] AddRange(TypedNameSeries namesAndTypes)
        {
            var seriesElements = namesAndTypes.ToArray();
            Stack <ILocalMemberDictionary> memberScopes = GetFullScope();

            IGeneralMemberUniqueIdentifier[] ids = new IGeneralMemberUniqueIdentifier[namesAndTypes.Count];
            for (int i = 0; i < seriesElements.Length; i++)
            {
                ids[i] = TypeSystemIdentifiers.GetMemberIdentifier(seriesElements[i].Name);
            }
            for (int i = 0; i < seriesElements.Length; i++)
            {
                var iElementIdentifier = ids[i];

                /* *
                 * First check for name collisions within the series itself.
                 * */
                for (int j = i + 1; j < seriesElements.Length; j++)
                {
                    if (iElementIdentifier.Equals(ids[j]))
                    {
                        throw new ArgumentException("Duplicate name detected");
                    }
                }

                /* *
                 * Next, check for collisions within the scope.
                 * */
                foreach (var scope in memberScopes)
                {
                    if (scope.ContainsKey(iElementIdentifier))
                    {
                        throw new ArgumentException("Duplicate name detected");
                    }
                }
            }
            var parentMember = this.GetTopParent() as IIntermediateMember;

            ITypedLocalMember[] locals = new ITypedLocalMember[seriesElements.Length];
            for (int i = 0; i < seriesElements.Length; i++)
            //Parallel.For(0, seriesElements.Length, i =>
            {
                var current   = seriesElements[i];
                var localType = current.GetTypeRef();
                if (localType.ContainsSymbols())
                {
                    localType = localType.SimpleSymbolDisambiguation(parentMember);
                }
                locals[i] = new TypedLocalMember(current.Name, this.Parent, localType);
            }//**/);
            this._AddRange(from local in locals
                           select new KeyValuePair <IGeneralMemberUniqueIdentifier, ILocalMember>(local.UniqueIdentifier, local));
            return(locals);
        }
 public ReferenceExpression(TypedLocalMember owner)
     : base(owner)
 {
 }