public RequiresThreeDisposables(
     Disposable first,
     Disposable2 second,
     Disposable3 third)
 {
     First  = first;
     Second = second;
     Third  = third;
 }
예제 #2
0
 public Service1(Disposable2 disposable2)
 {
     this.disposable2 = disposable2;
 }
예제 #3
0
 public void Dispose()
 {
     second = new Disposable2("Goodbye!");
 }
        public void Execute()
        {
            //
            // 通常パターン.
            //
            using (var disposable1 = new Disposable1())
            {
                using (var disposable2 = new Disposable2())
                {
                    using (var disposable3 = new Disposable3())
                    {
                        Output.WriteLine("Dispose Start..");
                    }
                }
            }

            //
            // 通常パターン: DisposableManager利用.
            //
            using (var manager = new DisposableManager())
            {
                manager.Add(new Disposable1());
                manager.Add(new Disposable2());
                manager.Add(new Disposable3());

                Output.WriteLine("Dispose Start..");
            }

            //
            // 条件が存在し、作成されないオブジェクトが存在する可能性がある場合.
            //
            Disposable1 dispose1 = null;
            Disposable2 dispose2 = null;
            Disposable3 dispose3 = null;

            var isDispose2Create = false;

            try
            {
                dispose1 = new Disposable1();

                if (isDispose2Create)
                {
                    dispose2 = new Disposable2();
                }

                dispose3 = new Disposable3();
            }
            finally
            {
                Output.WriteLine("Dispose Start..");
                DisposeIfNotNull(dispose1);
                DisposeIfNotNull(dispose2);
                DisposeIfNotNull(dispose3);
            }


            //
            // 条件あり: DisposableManager利用.
            //
            dispose1 = null;
            dispose2 = null;
            dispose3 = null;

            using (var manager = new DisposableManager())
            {
                dispose1 = manager.Add(new Disposable1());

                if (isDispose2Create)
                {
                    dispose2 = manager.Add(new Disposable2());
                }

                dispose3 = manager.Add(new Disposable3());

                Output.WriteLine("Dispose Start..");
            }
        }
예제 #5
0
 public Disposable1(Disposable2 innerDisposable, EventTracker tracker)
 {
     _tracker = tracker;
 }
 public Disposable1(Disposable2 innerDisposable, EventTracker tracker)
 {
     _tracker = tracker;
 }
예제 #7
0
 public Service1(Disposable2 disposable2)
 {
     this.disposable2 = disposable2;
 }
 public RequiresScopeAndDisposable2(ContainerScope scope, Disposable2 disposable, RequiresScopeAndDisposable3 next)
 {
     Scope      = scope;
     Disposable = disposable;
     Next       = next;
 }