public static IContainer CreateContainer() { string settingsFolderPath = ApplicationBuildConfig.UserDataPath; string iniConfigFilePath = Path.Combine(ApplicationBuildConfig.UserDataPath, "ApplicationSettings.ini"); var appSettings = new AppSettingsService(ConfigHelper.GetDefaultSettings(), new IniConfigFileManager(), iniConfigFilePath); var memoStorageService = new MemoStorageService(appSettings, settingsFolderPath); // Create autofac container var builder = new ContainerBuilder(); builder.RegisterInstance(appSettings).As <AppSettingsService>(); builder.RegisterInstance(memoStorageService).As <MemoStorageService>(); var generalToolKitAssembly = AssemblyHelper.GetAssembly(); if (generalToolKitAssembly != null) { builder.RegisterAssemblyModules(generalToolKitAssembly); } builder.RegisterAssemblyModules(Assembly.GetCallingAssembly()); var container = builder.Build(); return(container); }
/// <summary> /// Initializes a new instance of the <see cref="MainFormLogicManager" /> class. /// </summary> /// <param name="memoStorageService">The memo storage service.</param> /// <param name="fileStorageService">The file storage service.</param> /// <param name="passwordStorage">The password storage.</param> /// <param name="scope">The scope.</param> /// <param name="appSettingsService">The application settings service.</param> public MainFormLogicManager(MemoStorageService memoStorageService, FileStorageService fileStorageService, PasswordStorage passwordStorage, ILifetimeScope scope, AppSettingsService appSettingsService) { _memoStorageService = memoStorageService; _fileStorageService = fileStorageService; _scope = scope; _appSettingsService = appSettingsService; _passwordStorage = passwordStorage; _tabPageDataCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages); }
/// <summary> /// Creates the Autofac container. /// </summary> /// <returns></returns> public static IContainer CreateContainer() { string settingsFolderPath = ApplicationBuildConfig.UserDataPath; string iniConfigFilePath = Path.Combine(ApplicationBuildConfig.UserDataPath, "ApplicationSettings.ini"); var appSettings = new AppSettingsService(ConfigHelper.GetDefaultSettings(), new IniConfigFileManager(), iniConfigFilePath); var memoStorageService = new MemoStorageService(appSettings, settingsFolderPath); var passwordStorageMgr = new PasswordStorage(); // Create autofac container var builder = new ContainerBuilder(); builder.RegisterInstance(appSettings).As <AppSettingsService>().SingleInstance(); builder.RegisterInstance(memoStorageService).As <MemoStorageService>().SingleInstance(); builder.RegisterInstance(new FileStorageService()).As <FileStorageService>().SingleInstance(); builder.RegisterInstance(passwordStorageMgr).As <PasswordStorage>().SingleInstance(); var generalToolKitAssembly = AssemblyHelper.GetAssembly(); if (generalToolKitAssembly != null) { builder.RegisterAssemblyModules(generalToolKitAssembly); } builder.RegisterAssemblyModules(Assembly.GetExecutingAssembly()); builder.RegisterType <MainFormLogicManager>().AsSelf().SingleInstance(); builder.RegisterType <ServiceBase>().AsImplementedInterfaces().InstancePerLifetimeScope(); // Register instantiation of Search engine builder.RegisterType <TabSearchEngine>().AsSelf().InstancePerLifetimeScope(); // Register Automapper and configure the mapping bindings builder.Register(context => context.Resolve <MapperConfiguration>() .CreateMapper()) .As <IMapper>() .AutoActivate() .SingleInstance(); builder.Register(Configure) .AutoActivate() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); var container = builder.Build(); return(container); }
public FormMain(AppSettingsService appSettingsService, MemoStorageService memoStorageService, PasswordStorage passwordStorage, ILifetimeScope scope) { if (DesignMode) { return; } _appSettingsService = appSettingsService; _memoStorageService = memoStorageService; _passwordStorage = passwordStorage; _scope = scope; _applicationState = new ApplicationState(); _tabPageDataCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages); _licenseService = LicenceService.Instance; InitializeComponent(); }
public FormRestoreBackup(MemoStorageService memoStorageService) { _memoStorageService = memoStorageService; InitializeComponent(); }