Beispiel #1
0
        public void Unmanaged_when_Dispose()
        {
            var d        = new DisposableObject();
            var disposer = new UnmanagedOptionDisposer(d);

            d.IsDisposed.IsFalse();
            d.IsOpenedUnmanagedResource.IsTrue();

            disposer.Dispose();     // call DisposeUnmanagedObjects()

            d.IsDisposed.IsTrue();
            d.IsOpenedUnmanagedResource.IsFalse();   // release unmanaged resources
        }
Beispiel #2
0
        public void Unmanaged_do_not_work()
        {
            var d        = new DisposableObject();
            var disposer = new NoneOptionDisposer(d);

            d.IsDisposed.IsFalse();
            d.IsOpenedUnmanagedResource.IsTrue();

            disposer.Dispose();

            d.IsDisposed.IsTrue();
            d.IsOpenedUnmanagedResource.IsTrue();   // Did not release resources
        }
        public void SetNull_do_not_work()
        {
            var d        = new DisposableObject();
            var disposer = new NoneOptionDisposer(d);

            d.IsDisposed.IsFalse();
            d.NullableValue.IsNotNull();

            disposer.Dispose();

            d.IsDisposed.IsTrue();
            d.NullableValue.IsNotNull();    // Did not set null
        }
        public void SetNull_when_Dispose()
        {
            var d        = new DisposableObject();
            var disposer = new OnDisposingDisposer(d);

            d.IsDisposed.IsFalse();
            d.NullableValue.IsNotNull();

            disposer.Dispose();         // call OnDisposing()

            d.IsDisposed.IsTrue();
            d.NullableValue.IsNull();   // set field to null
        }
Beispiel #5
0
        public void SetNull_when_Dispose()
        {
            var d        = new DisposableObject();
            var disposer = new FieldsNullDisposer(d);

            d.IsDisposed.IsFalse();
            d.NullableValue.IsNotNull();

            disposer.Dispose();         // call SetLargeFieldsToNull()

            d.IsDisposed.IsTrue();
            d.NullableValue.IsNull();   // set field to null
        }
Beispiel #6
0
 public UnmanagedOptionDisposer(DisposableObject d)
 {
     _obj = d;
     _disposables.Add(d);
 }
 public OnDisposingDisposer(DisposableObject d)
 {
     _obj = d;
     _disposables.Add(d);
 }
Beispiel #8
0
 public FieldsNullDisposer(DisposableObject d)
 {
     _obj = d;
     _disposables.Add(d);
 }
 public NamePropertyDisposer(DisposableObject d)
 {
     _obj = d;
     _myDisposables.Add(d);  // set field name
 }