Exemple #1
0
 internal _EnumTypeBase(IEnumType original, IControlledTypeCollection genericParameters)
 {
     if (!(genericParameters is LockedTypeCollection))
         genericParameters = genericParameters.ToLockedCollection();
     this.original = original;
     this.genericParameters = (LockedTypeCollection)genericParameters;
     /* *
      * Allow the original to cache this series of generic
      * parameters to the current instance.
      * */
     if (original is _IGenericClosureRegistrar)
         ((_IGenericClosureRegistrar)(original)).RegisterGenericClosure(this, this.genericParameters);
     foreach (var type in this.genericParameters)
         type.Disposed += new EventHandler(genericParameter_Disposed);
     this.Original = original;
 }
Exemple #2
0
        /// <summary>
        /// Returns a <typeparamref name="TType"/> instance that is the
        /// closed generic form of the current <see cref="IntermediateGenericTypeBase{TTypeIdentifier, TType, TIntermediateType}"/>
        /// using the <paramref name="typeParameters"/> provided.
        /// </summary>
        /// <param name="typeParameters">The <see cref="ILockedTypeCollection"/>
        /// used to fill in the type-parameters.</param>
        /// <returns>A new closed <typeparamref name="TType"/> instance with
        /// the <paramref name="typeParameters"/> provided.</returns>
        /// <exception cref="System.InvalidOperationException">
        /// The current <see cref="IntermediateGenericTypeBase{TTypeIdentifier, TType, TIntermediateType}"/>'s
        /// <seealso cref="IsGenericDefinition"/>
        /// is false.</exception>
        public TType MakeGenericClosure(IControlledTypeCollection typeParameters)
        {
            LockedTypeCollection lockedTypeParameters = typeParameters.ToLockedCollection();
            IGenericType         genericResult;

            lock (this.SyncObject)
                if (this.genericCache != null && genericCache.TryObtainGenericClosure(lockedTypeParameters, out genericResult))
                {
                    return((TType)genericResult);
                }
                else
                {
                    if (this.genericCache == null)
                    {
                        this.genericCache = new GenericTypeCache();
                    }
                    var result = this.OnMakeGenericClosure(lockedTypeParameters);
                    this.genericCache.RegisterGenericType(result, lockedTypeParameters);
                    return(result);
                }
        }
Exemple #3
0
        public ISymbolType MakeGenericClosure(IControlledTypeCollection typeParameters)
        {
            if (typeParameters == null)
            {
                throw new ArgumentNullException("typeParameters");
            }
            if (!this.IsGenericDefinition)
            {
                throw new System.InvalidOperationException();
            }
            if (typeParameters.Count != this.GenericParameters.Count)
            {
                throw ThrowHelper.ObtainArgumentException(ArgumentWithException.typeParameters, ExceptionMessageId.GenericClosureReplacementCount);
            }
            var lockedTypeParameters = typeParameters.ToLockedCollection();

            lock (this.SyncObject)
                if (this.genericCache != null && this.genericCache.ContainsGenericClosure(lockedTypeParameters))
                {
                    return((ISymbolType)genericCache.ObtainGenericClosure(lockedTypeParameters));
                }
            return(this.OnMakeGenericClosure(lockedTypeParameters));
        }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="source"/>,
 /// <paramref name="genericParameters"/> and
 /// <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="source">The <see cref="IMemberParentReferenceExpression"/>
 /// from which the <see cref="UnboundMethodReferenceStub"/> was sourced.</param>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public MethodReferenceStubBase(IMemberParentReferenceExpression source, IControlledTypeCollection genericParameters = null, MethodReferenceType referenceType = MethodReferenceType.VirtualMethodReference)
 {
     if (genericParameters != null)
     {
         this.genericParameters = genericParameters is ILockedTypeCollection ? ((ILockedTypeCollection)(genericParameters)) : genericParameters.ToLockedCollection();
     }
     this.referenceType = referenceType;
     this.source        = source;
 }