Пример #1
0
 private void DisposeCore(bool disposing)
 {
     if (Interlocked.Exchange(ref this.isDisposed, 1) == 0)
     {
         try
         {
             this.Dispose(disposing);
         }
         finally
         {
             IObjectRef innerRef = this.innerRef;
             this.InnerRef = null;
             if ((this.proxyOptions & ObjectRefProxyOptions.DoNotCreateRef) != ObjectRefProxyOptions.DoNotCreateRef)
             {
                 IRefTrackedObject obj2 = innerRef as IRefTrackedObject;
                 if (obj2 != null)
                 {
                     obj2.ReleaseRef(this, disposing);
                 }
             }
         }
         if (disposing)
         {
             RefTrackedObject cleanupContainer;
             ObjectRefProxy proxy = this;
             lock (proxy)
             {
                 cleanupContainer = this.cleanupContainer;
                 this.cleanupContainer = null;
             }
             DisposableUtil.Free<RefTrackedObject>(ref cleanupContainer, disposing);
         }
     }
 }
Пример #2
0
 private void Initialize(bool constructing)
 {
     if ((this.proxyOptions & ObjectRefProxyOptions.DoNotCreateRef) != ObjectRefProxyOptions.DoNotCreateRef)
     {
         IRefTrackedObject innerRef = this.innerRef as IRefTrackedObject;
         if (!innerRef.IsNullReference<IRefTrackedObject>())
         {
             innerRef.AddRef<IRefTrackedObject>(this);
         }
         else if (constructing)
         {
             this.AddCleanupRef(this.innerRef);
         }
     }
     if (constructing && ((this.proxyOptions & ObjectRefProxyOptions.DisposeInnerRef) == ObjectRefProxyOptions.DisposeInnerRef))
     {
         this.AddCleanupObject(this.innerRef);
     }
 }