예제 #1
0
    public ActionResult Index(int id)
    {
        var model = new Model();

        model.Customer = this.dataAccess.Get(id);
        Owned <DataAccess> dataAccessForAsyncTaskHolder = null;

        try
        {
            dataAccessForAsyncTaskHolder = dataAccessFactory();
            dataAccessForAsyncTaskHolder.Value.ExecuteAsyncTask(() =>
                                                                // you'll need a completion callback
            {
                // finish the task if required
                // dipose the owned instance
                dataAccessForAsyncTaskHolder.Dispose();
            });
        }
        catch
        {
            if (dataAccessForAsyncTaskHolder != null)
            {
                dataAccessForAsyncTaskHolder.Dispose();
            }
            throw;
        }
        return(View(model));
    }
예제 #2
0
        private async Task Handle(SuccesLogin authorization)
        {
            logger.Info("Handle SuccesLogin");

            Loading = true;
            loginViewModel.Dispose();
            Loading = false;

            await base.BeginLogonSession();
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _ownedValue.Dispose();
     }
 }
예제 #4
0
파일: OwnedTests.cs 프로젝트: Ankitvaibs/SM
 public void DisposingOwned_CallsDisposeOnLifetimeToken()
 {
     var lifetime = new DisposeTracker();
     var owned = new Owned<string>("unused", lifetime);
     owned.Dispose();
     Assert.True(lifetime.IsDisposed);
 }
예제 #5
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         _ownedInstance?.Dispose();
     }
 }
예제 #6
0
 public void DisposingOwned_CallsDisposeOnLifetimeToken()
 {
     var lifetime = new DisposeTracker();
     var owned = new Owned<string>("unused", lifetime);
     owned.Dispose();
     Assert.True(lifetime.IsDisposed);
 }
예제 #7
0
            public void ReportOnce()
            {
                log.Value.Write("Log started");

                // we do not call log.Value.Dispose() - slight difference in syntax
                log.Dispose();
                Console.WriteLine("Log disposed");
            }
예제 #8
0
        public void M()
        {
            //_b用于某个任务
            _b.Value.DoSomething();

            //这里_b不再需要,所以它被释放
            _b.Dispose();
        }
예제 #9
0
        public void DisposingOwned_CallsDisposeOnLifetimeToken()
        {
            var o     = new MockDisposable();
            var owned = new Owned <string>("unused", o);

            owned.Dispose();
            Assert.AreEqual(1, o.disposed);
        }
예제 #10
0
 public void DisposingOwned_CallsDisposeOnLifetimeToken()
 {
     var lifetime = new Mock<IDisposable>();
     lifetime.Setup(l => l.Dispose()).Verifiable();
     var owned = new Owned<string>("unused", lifetime.Object);
     owned.Dispose();
     lifetime.VerifyAll();
 }
        protected override void Dispose(bool disposing)
        {
            if (_optionsPageControl != null)
            {
                _optionsPageControl.Dispose();
            }

            base.Dispose(disposing);
        }
예제 #12
0
        public void DisposingOwned_CallsDisposeOnLifetimeToken()
        {
            var lifetime = new Mock <IDisposable>();

            lifetime.Setup(l => l.Dispose()).Verifiable();
            var owned = new Owned <string>("unused", lifetime.Object);

            owned.Dispose();
            lifetime.VerifyAll();
        }
 public void Handle()
 {
     try
     {
         _command.Value.Execute();
     }
     finally
     {
         _command.Dispose();
     }
 }
예제 #14
0
 protected virtual void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (disposing)
     {
         _hostEvents.Dispose();
         _siteLifetimeScope.Dispose();
         _rootLifetimeScope.Dispose();
     }
     _disposed = true;
 }
예제 #15
0
        public async Task Run(IWorkContext context)
        {
            context.Verify(nameof(context)).IsNotNull();
            context = context
                      .WithCreateLogger(nameof(SendEvents))
                      .With(_tag);

            context.Telemetry.Info(context, $"Sending events, Task Count:{_option.TaskCount}, ...");

            try
            {
                await SendMessagesToEventHub(context);
            }
            finally
            {
                await _sendEvent.Value.CloseAsync(context);

                _sendEvent.Dispose();
            }

            context.Telemetry.Info(context, "Completed sending events...");
        }
예제 #16
0
 public void ReportOnce()
 {
     ownedLogger.Value.Write("Report once");
     ownedLogger.Dispose();
 }
예제 #17
0
 public void ReportOnce()
 {
     _loggerOwned.Value.Write("Log started");
     _loggerOwned.Dispose();
 }
 public void Report()
 {
     log.Value.Write("Report from consolelog");
     log.Dispose();
 }
 public void Dispose()
 {
     _ownedExecutor.Dispose();
 }
 public void Dispose()
 {
     _ownedDeployer.Dispose();
 }
예제 #21
0
 public void The_Dipose_call_count_is_1()
 {
     _ownedDisposable.Dispose();
     Assert.AreEqual(1, Disposable.DisposeCallCount);
 }
 public void ReportOnce()
 {
     log.Value.Write("Log started");
     log.Dispose(); // ConsoleLog의 Dispose()가 아니라 Autofac의 Dispose()이다
 }
예제 #23
0
 public void Stop()
 {
     cancellationTokenSource.Cancel();
     watchdog?.Dispose();
     watchdog = null;
 }
예제 #24
0
 public void Dispose()
 {
     UnsubscrubeOnExchangesEvents();
     _produserOwner.Dispose();
 }
 public void ReportOnce()
 {
     log.Value.Write("Log started");
     log.Dispose();
 }
예제 #26
0
파일: OwnedTests.cs 프로젝트: jrjohn/Grace
        public void SimpleDisposableTest()
        {
            Owned<IDisposableService> owned = new Owned<IDisposableService>();
            DisposableService disposableService = new DisposableService();
            bool eventFired = false;

            disposableService.Disposing += (sender, args) => eventFired = true;

            owned.SetValue(disposableService);

            Assert.True(ReferenceEquals(owned.Value, disposableService));

            owned.Dispose();

            Assert.True(eventFired);
        }
예제 #27
0
 public void Report(string message)
 {
     _log.Value.Log(message);
     _log.Dispose();
 }
예제 #28
0
 private void OnUnloaded(object sender, RoutedEventArgs e)
 {
     OnUnloaded();
     View = null;
     _owned?.Dispose();
 }
예제 #29
0
파일: Xxx.cs 프로젝트: Rennbon/AutoFac
 public void Dispose()
 {
     _xxx.Dispose();
 }
예제 #30
0
 public void Dispose()
 {
     _root.Dispose();
 }
 public void ReportOnce()
 {
     log.Value.Write("Log started");
     log.Dispose(); // Call it on owned type
 }
예제 #32
0
 public void PrintToken()
 {
     Console.WriteLine(_ownedDtoToken?.Value?.Guid);
     _ownedDtoToken?.Dispose();
 }
예제 #33
0
파일: OwnedTests.cs 프로젝트: jrjohn/Grace
        public void SimpleNonDisposableTest()
        {
            Owned<IBasicService> owned = new Owned<IBasicService>();
            BasicService basicService = new BasicService();

            owned.SetValue(basicService);

            Assert.True(ReferenceEquals(owned.Value, basicService));

            owned.Dispose();
        }
 /// <summary>
 /// Disposes of the owned instance.
 /// </summary>
 public override void Dispose()
 {
     owned.Dispose();
 }