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); } } }
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; }
public void RegisterGenericClosure(IGenericType targetType, ILockedTypeCollection typeParameters) { lock (this.SyncObject) { if (this.genericCache == null) { this.genericCache = new GenericTypeCache(); } this.genericCache.RegisterGenericType(targetType, typeParameters); } }
public void UnregisterGenericClosure(ILockedTypeCollection typeParameters) { lock (this.SyncObject) { if (this.genericCache == null) { return; } this.genericCache.UnregisterGenericType(typeParameters); } }
public bool ContainsGenericClosure(ILockedTypeCollection typeParameters) { lock (this.SyncObject) { if (this.genericCache == null) { return(false); } return(this.genericCache.ContainsGenericClosure(typeParameters)); } }
public IGenericType ObtainGenericClosure(ILockedTypeCollection typeParameters) { lock (this.SyncObject) { if (this.genericCache == null) { return(null); } return(this.genericCache.ObtainGenericClosure(typeParameters)); } }
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)); } }
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(); }
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); }
/// <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()); } }
/// <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); } }
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; }
private ILockedTypeCollection InitializeImplementedInterfaces() { return(this.implInterfaces != null ? this.implInterfaces : (this.implInterfaces = new LockedTypeCollection(GetImplementedInterfacesInternal()))); }
protected override ILockedTypeCollection OnGetImplementedInterfaces() { return(implInterfaces ?? (implInterfaces = this.InitializeImplementedInterfaces())); }
void _IGenericClosureRegistrar.RegisterGenericClosure(IGenericType targetType, ILockedTypeCollection typeParameters) { this.RegisterGenericType(targetType, typeParameters); }
void _IGenericClosureRegistrar.UnregisterGenericClosure(ILockedTypeCollection typeParameters) { this.UnregisterGenericType(typeParameters); }