Beispiel #1
0
 internal void UnregisterGenericType(ILockedTypeCollection typeParameters)
 {
     if (typeParameters == null)
     {
         return;
     }
     lock (this.syncObject)
     {
         if (this.exodusCache != null)
         {
             this.exodusCache.Add(typeParameters);
             return;
         }
         if (this.genericCache == null || this.disposing)
         {
             return;
         }
         IGenericType unregistered;
         if (this.genericCache.TryGetValue(typeParameters, out unregistered))
         {
             unregistered.Dispose();
             this.genericCache.Remove(typeParameters);
         }
     }
 }
Beispiel #2
0
 public override void Dispose()
 {
     try
     {
         lock (this.SyncObject)
         {
             if (this.metadata != null)
             {
                 this.metadata.Dispose();
                 this.metadata = null;
             }
             if (this.constraints != null)
             {
                 this.constraints.Clear();
                 this.constraints = null;
             }
             if (this._constraints != null)
             {
                 this._constraints.Dispose();
                 this._constraints = null;
             }
             if (this.constructors != null)
             {
                 this.constructors.Dispose();
                 this.constructors = null;
             }
             if (this.events != null)
             {
                 this.events.Dispose();
                 this.events = null;
             }
             if (this.indexers != null)
             {
                 this.indexers.Dispose();
                 this.indexers = null;
             }
             if (this.methods != null)
             {
                 this.methods.Dispose();
                 this.methods = null;
             }
             if (this.properties != null)
             {
                 this.properties.Dispose();
                 this.properties = null;
             }
             if (this._members != null)
             {
                 this._members.Dispose();
                 this._members = null;
             }
         }
     }
     finally
     {
         base.Dispose();
     }
 }
 /// <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;
 }
Beispiel #4
0
 public void RegisterGenericClosure(IGenericType targetType, ILockedTypeCollection typeParameters)
 {
     lock (this.SyncObject)
     {
         if (this.genericCache == null)
         {
             this.genericCache = new GenericTypeCache();
         }
         this.genericCache.RegisterGenericType(targetType, typeParameters);
     }
 }
Beispiel #5
0
 public void UnregisterGenericClosure(ILockedTypeCollection typeParameters)
 {
     lock (this.SyncObject)
     {
         if (this.genericCache == null)
         {
             return;
         }
         this.genericCache.UnregisterGenericType(typeParameters);
     }
 }
Beispiel #6
0
 public bool ContainsGenericClosure(ILockedTypeCollection typeParameters)
 {
     lock (this.SyncObject)
     {
         if (this.genericCache == null)
         {
             return(false);
         }
         return(this.genericCache.ContainsGenericClosure(typeParameters));
     }
 }
Beispiel #7
0
 public IGenericType ObtainGenericClosure(ILockedTypeCollection typeParameters)
 {
     lock (this.SyncObject)
     {
         if (this.genericCache == null)
         {
             return(null);
         }
         return(this.genericCache.ObtainGenericClosure(typeParameters));
     }
 }
Beispiel #8
0
 public bool TryObtainGenericClosure(ILockedTypeCollection typeParameters, out IGenericType genericClosure)
 {
     lock (this.SyncObject)
     {
         if (this.genericCache == null)
         {
             genericClosure = null;
             return(false);
         }
         return(this.genericCache.TryObtainGenericClosure(typeParameters, out genericClosure));
     }
 }
Beispiel #9
0
 public override void Dispose()
 {
     if (this.typeParameters != null)
     {
         this.typeParameters.Dispose();
         this.typeParameters = null;
     }
     if (this.GenericReplacementsImpl != null)
     {
         this.GenericReplacementsImpl.Dispose();
         this.GenericReplacementsImpl = null;
     }
     base.Dispose();
 }
Beispiel #10
0
 protected override ILockedTypeCollection OnGetGenericParameters()
 {
     if (this.typeParameters == null)
     {
         if (this.GenericReplacementsImpl == null)
         {
             this.typeParameters = this.TypeParameters.Values.ToLockedCollection();
         }
         else
         {
             this.typeParameters = this.GenericReplacementsImpl;
         }
     }
     return(this.typeParameters);
 }
Beispiel #11
0
 /// <summary>
 /// Returns a collection of <see cref="IType"/> instances that are directly implemented by the current
 /// <see cref="IType"/>.
 /// </summary>
 /// <returns>A <see cref="ILockedTypeCollection"/> which represents the <see cref="IType"/> instances which directly implemented by the current
 /// <see cref="TypeBase{TIdentifier}"/></returns>
 public ILockedTypeCollection GetDirectlyImplementedInterfaces()
 {
     if (this.CanCacheImplementsList)
     {
         lock (this.syncObject)
         {
             if (this.directImplementedInterfaces == null)
             {
                 this.directImplementedInterfaces = this.OnGetDirectImplementedInterfaces();
             }
             return(this.directImplementedInterfaces);
         }
     }
     else
     {
         return(this.OnGetDirectImplementedInterfaces());
     }
 }
Beispiel #12
0
 /// <summary>
 /// Registers a generic type with the <paramref name="targetType"/> and
 /// <paramref name="typeParameters"/> provided.
 /// </summary>
 /// <param name="targetType">The <see cref="IGenericType"/>
 /// which represents the specific generic instance of the user of the
 /// <see cref="GenericTypeCache"/>.</param>
 /// <param name="typeParameters">The series of <see cref="IType"/>
 /// instances which replace the type-parameters of the type the
 /// <see cref="GenericTypeCache"/> is used by.</param>
 internal void RegisterGenericType(IGenericType targetType, ILockedTypeCollection typeParameters)
 {
     if (typeParameters == null)
     {
         return;
     }
     lock (syncObject)
     {
         if (this.genericCache == null)
         {
             this.genericCache = new Dictionary <ILockedTypeCollection, IGenericType>();
         }
         if (this.genericCache.ContainsKey(typeParameters))
         {
             return;
         }
         genericCache.Add(new LockedTypeCollection(typeParameters), (IGenericType)targetType);
     }
 }
Beispiel #13
0
 public _MethodSignatureMemberBase(TSignature original, IControlledTypeCollection genericReplacements)
     : base(original.Parent)
 {
     /* *
      * Lock the series if it's not already.
      * */
     if (!(genericReplacements is ILockedTypeCollection))
     {
         genericReplacements = new LockedTypeCollection(genericReplacements);
     }
     if (original is _IGenericMethodSignatureRegistrar)
     {
         ((_IGenericMethodSignatureRegistrar)(original)).RegisterGenericMethod((IMethodSignatureMember)(this), genericReplacements);
     }
     else if (original is _IGenericMethodRegistrar)
     {
         ((_IGenericMethodRegistrar)(original)).RegisterGenericMethod((IMethodMember)(this), genericReplacements);
     }
     this.GenericReplacementsImpl = (ILockedTypeCollection)genericReplacements;
     this.original = original;
 }
Beispiel #14
0
 private ILockedTypeCollection InitializeImplementedInterfaces()
 {
     return(this.implInterfaces != null ? this.implInterfaces : (this.implInterfaces = new LockedTypeCollection(GetImplementedInterfacesInternal())));
 }
Beispiel #15
0
 protected override ILockedTypeCollection OnGetImplementedInterfaces()
 {
     return(implInterfaces ?? (implInterfaces = this.InitializeImplementedInterfaces()));
 }
Beispiel #16
0
 void _IGenericClosureRegistrar.RegisterGenericClosure(IGenericType targetType, ILockedTypeCollection typeParameters)
 {
     this.RegisterGenericType(targetType, typeParameters);
 }
Beispiel #17
0
 void _IGenericClosureRegistrar.UnregisterGenericClosure(ILockedTypeCollection typeParameters)
 {
     this.UnregisterGenericType(typeParameters);
 }