public static void DisposeThis() { if (_kernel != null) { _kernel.Dispose(); } }
public void Dispose() { if (!_kernel.IsDisposed) { _kernel.Dispose(); } }
private static void Main(string[] args) { errorWriter = new StreamWriter("error.log"); AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; kernel = new StandardKernel(); kernel.Load<DefaultModule>(); //TODO: IConfiguration. Unit tests! int configuredMaxTableSize = Convert.ToInt32(ConfigurationManager.AppSettings["MaximumTableSize"]); int maxTableSize = configuredMaxTableSize <= 255 ? 10000 : configuredMaxTableSize; if(ConfigurationManager.AppSettings["DataStructureToUse"] == "BinarySearchTree") { kernel.Load(new BinarySearchTreeModule(maxTableSize)); } else { kernel.Load(new FrameworkDictionaryModule(maxTableSize)); } var argumentParser = kernel.Get<CommandLineArgumentParser>(); ICommand command = argumentParser.Parse(args); command.Execute(); kernel.Dispose(); errorWriter.Dispose(); }
public void DisposeObjects() { if (_kernel != null) { _kernel.Dispose(); } }
public void Dispose() { if (kernel != null) { kernel.Dispose(); } }
protected void Dispose(bool disposing) { if (disposing && _kernel != null) { _kernel.Dispose(); } }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { var modules = new INinjectModule[] { new DIResolver("ProdConection") }; // передаем ядру модули конфигурации (modules), реализующие интерфейс INinjectModule Kernel = new StandardKernel(modules); try { Kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel); Kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>(); //web api set GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(Kernel); // Resolver DI - WebApiContrib.IoC.Ninject RegisterServices(Kernel); return(Kernel); } catch { Kernel.Dispose(); throw; } }
/// <summary> /// To be called on App Exit /// </summary> public static void Dispose() { LoadedModules.ForEach(M => M.Dispose()); // Singleton objects will be disposed by Kernel Kernel.Dispose(); }
public static IKernel GetKernel <T>() where T : NinjectModule, new() { if (_kernel == null) { lock (Lock) if (_kernel == null) { _kernel = new StandardKernel(); try { _kernel.Load(new T()); _kernel.Get <AC>(); var dbContext = _kernel.Get <ProjectContext>(); var dbFileContext = _kernel.Get <ProjectFilesContext>(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <ProjectContext, DataAccess.Database1.Migrations.Configuration>()); Database.SetInitializer(new MigrateDatabaseToLatestVersion <ProjectFilesContext, DataAccess.Database1.Files.Migrations.Configuration>()); dbContext.Database.Initialize(false); dbFileContext.Database.Initialize(false); } catch { _kernel.Dispose(); throw; } } } return(_kernel); }
public void TestFixtureTearDown() { if (_kernel != null) { _kernel.Dispose(); } }
private void CloseApp() { HideTray(); if (closed == false) { var app = _kernel?.Get <IAppService>(); var window = MainWindow; if (window != null) { MainWindow.Closing -= MainWindow_Closing; window.Hide(); window.Close(); } if (app != null) { app.Stop(); } _kernel?.Dispose(); //await Container.StopAsync(); //Container.Dispose(); closed = true; } _job?.Dispose(); Application.Current.Shutdown(); }
private void ShutdownAddIn() { Debug.WriteLine("Extension unhooking VBENativeServices events."); VBENativeServices.UnhookEvents(); var currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve -= LoadFromSameFolder; Debug.WriteLine("Extension broadcasting shutdown."); User32.EnumChildWindows(_ide.MainWindow.Handle(), EnumCallback, new IntPtr(0)); Debug.WriteLine("Extension calling ReleaseDockableHosts."); VBEditor.SafeComWrappers.VBA.Windows.ReleaseDockableHosts(); if (_app != null) { Debug.WriteLine("Extension calling App.Shutdown."); _app.Shutdown(); _app = null; } if (_kernel != null) { Debug.WriteLine("Extension calling Kernel.Dispose."); _kernel.Dispose(); _kernel = null; } _isInitialized = false; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _customToolRunner.Dispose(); _kernel.Dispose(); }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> public static IKernel CreateKernel() { Kernel = new StandardKernel(); try { Kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel); Kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>(); string IotHubOwnerConnectionString = ConfigurationManager.AppSettings["IotHubOwnerConnectionString"]; string IotHubServiceConnectionString = ConfigurationManager.AppSettings["IotHubServiceConnectionString"]; string blobConnectionString = ConfigurationManager.AppSettings["BlobConnectionString"]; Kernel.Bind <IBlobService>().To <BlobService>() .InRequestScope() .WithConstructorArgument("connectionString", blobConnectionString) .WithConstructorArgument("containerName", "demo"); Kernel.Bind <IServerIoTService>().To <ServerIoTService>() .InRequestScope() .WithConstructorArgument("serviceConnectionString", IotHubServiceConnectionString) .WithConstructorArgument("registryConnectionString", IotHubOwnerConnectionString) .WithConstructorArgument("transport", TransportType.Amqp); return(Kernel); } catch (Exception ex) { Kernel.Dispose(); throw; } }
public static void AssemblyCleanup() { var dbContext = Kernel.Get <ProjectContext>(); dbContext.Database.ExecuteSqlCommand($"delete from dbo.[User]"); Kernel.Dispose(); }
public void Dispose() { var dp = _kernel.Get <IDataProvider>(); dp.Dispose(); _kernel.Dispose(); }
private void Dispose(bool isDisposing) { if (isDisposing) { kernel.Dispose(); } }
/// <summary> /// Releases all resourced used by the <see cref="OwinRestService"/> instance. /// </summary> public void Dispose() { hostKernel?.Dispose(); hostKernel = null; owinInstance?.Dispose(); owinInstance = null; }
private void DisposeKernel() { if (_kernel != null) { _kernel.Dispose(); _kernel = null; } }
public void Dispose() { if (Kernel != default(IKernel)) { KernelCache.Clear(); Kernel.Dispose(); } }
private void Dispose(bool isDisposing) { if (isDisposing) { _kernel.Dispose(); _mediator.Dispose(); } }
public void AutoDisposeCallTest() { container.AutoBinding(Profiles.PROFILE_C); IBindableService instance = container.Get <IBindableService>(); container.Dispose(); }
public void TearDown() { if (kernel != null) { kernel.Dispose(); } kernel = null; }
protected virtual void Dispose(bool disposing) { if (_kernel != null) { _kernel.Dispose(); _kernel = null; } }
public void Dispose() { if (_DisposableKernel != null) { _DisposableKernel.Dispose(); _DisposableKernel = null; } }
public void UnloadKernel() { var res = pinzService.DeleteCompanyAsync(company); res.Wait(); kernel.Dispose(); }
/// <summary> /// Constructor. /// </summary> /// <param name="kernel"> /// Kernel to use. /// Use an instance of <see cref="IoCConfigurationNinjectKernel"/> to support binding some collection types, such as IEnumerable...(finish) /// </param> public NinjectDiContainer(IKernel kernel) { Kernel = kernel; MainLifeTimeScope = new NinjectLifeTimeScope(); CurrentLifeTimeScope = MainLifeTimeScope; MainLifeTimeScope.LifeTimeScopeTerminated += (sender, e) => { Kernel.Dispose(); }; }
public override void Dispose(bool disposing) { if (disposing && !IsDisposed) { _kernel.Dispose(); _kernel = null; } base.Dispose(disposing); }
public override void Dispose() { base.Dispose(); ScreenExtensions.TryDispose(_rootViewModel); if (Kernel != null) { Kernel.Dispose(); } }
/// <summary> /// Stops the application. /// </summary> public static void Stop() { if (_cqrsKernel != null) { _cqrsKernel.Dispose(); } bootstrapper.ShutDown(); }
public override void WillTerminate(NSNotification notification) { if (_kernel != null && !_kernel.IsDisposed) { _kernel.Get <IDbToolConfig>().SaveSettings(); _kernel.Dispose(); } _kernel = null; }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { kernel = new StandardKernel(); try { kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); RegisterServices(kernel); return kernel; } catch { kernel.Dispose(); throw; } }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> public static IKernel CreateKernel() { if (_kernel == null) { _kernel = new StandardKernel(); try { _kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); _kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); RegisterServices(_kernel); } catch { _kernel.Dispose(); throw; } } return _kernel; }
/// <summary> /// Creates the kernel that will manage your application. /// </summary> /// <returns>The created kernel.</returns> private static IKernel CreateKernel() { kernel = new StandardKernel( new DependancyResolution.EbayModule(), new Data(), new GenericFunctions()); try { kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); RegisterServices(kernel); return kernel; } catch { kernel.Dispose(); throw; } }