public static SimpleContainer GetPreconfiguredContainer()
        {
            var container = new SimpleContainer();

            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();
            container.PerRequest <IShell, ShellViewModel>();

            // WebAPI
            container.PerRequest <WebUIClient>();

            // UI.Torrent
            container.PerRequest <FilesViewModel>();
            container.PerRequest <GroupsViewModel>();
            container.PerRequest <InfoViewModel>();
            container.PerRequest <PeersViewModel>();
            container.PerRequest <RatingsViewModel>();
            container.PerRequest <SpeedViewModel>();
            container.PerRequest <StatusBarViewModel>();
            container.PerRequest <ToolBarViewModel>();
            container.PerRequest <TorrentsViewModel>();
            container.PerRequest <TrackersViewModel>();
            container.PerRequest <GroupItemViewModel>();
            container.Handler <IScreen>((c) => c.GetInstance <GroupItemViewModel>());

            // UI.Torrent.Client
            container.PerRequest <ClientSelectorViewModel>();
            container.PerRequest <ConnectionParamsViewModel>();
            container.Handler <IScreen>((c) => c.GetInstance <ConnectionParamsViewModel>());
            container.PerRequest <ClientViewModel>();
            container.Handler <IScreen>((c) => c.GetInstance <ClientViewModel>());

            // UI.Torrent.Preferences
            return(container);
        }
Exemple #2
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton <IWindowManager, MetroWindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();

            var baseExperienceData = new ExperienceData()
            {
                DisplayName = "Base Experience"
            };
            var classExperienceData = new ExperienceData()
            {
                DisplayName = "Class Experience"
            };

            IExperienceControl[] baseExperienceControls = GetExperienceControls(baseExperienceData, classExperienceData);

            ExperienceContainer experienceContainer = new ExperienceContainer(baseExperienceData, classExperienceData, baseExperienceControls);

            container.Handler <ShellViewModel>(simpleContainer =>
                                               new ShellViewModel(
                                                   container.GetInstance <SettingsViewModel>(),
                                                   experienceContainer,
                                                   new ExpCardCalculatorViewModel(experienceContainer),
                                                   container.GetInstance <IWindowManager>()));

            // TODO - refactor settings view model to just take a collection of menuitems
            container.Handler <SettingsViewModel>(simpleContainer => new SettingsViewModel(baseExperienceControls));
        }
 protected override void Configure()
 {
     container = new SimpleContainer();
     container.Singleton <IWindowManager, WindowManager>();
     container.Handler <ShellViewModel>(_ => new ShellViewModel(_myObjects));
     container.Handler <SomeOtherViewModel>(_ => new SomeOtherViewModel(_myObjects));
 }
Exemple #4
0
        protected override void Configure()
        {
            SetBindings();

            _container = new SimpleContainer();

            #region Configuration

            _container.Handler <IConfiguration>(_ => ConfigurationFactory.GetConfiguration());

            #region Options

            _container.AddRegisterOption <BalanceRange>();
            _container.AddRegisterOption <CurrencySettings>();

            #endregion

            #endregion

            #region Database

            _container.Handler <IAppDbContext>(x =>
            {
                var configuration = x.GetInstance <IConfiguration>();
                var connection    = configuration.GetConnectionString("DefaultConnection");

                var optionsBuilder = new DbContextOptionsBuilder <AppDbContext>();
                var options        = optionsBuilder.UseSqlite(connection).Options;
                var context        = new AppDbContext(options);
                return(context);
            });

            #endregion

            #region DI

            _container.PerRequest <IBarcodeProducer, BarcodeProducer>();
            _container.Singleton <IMapperProvider, DomainToServiceMapper>();
            _container.PerRequest <IImageProducer, ImageProducer>();
            _container.Singleton <IWindowManager, WindowManager>();
            _container.PerRequest <IOrderArchive, OrderArchive>();
            _container.PerRequest <IProductRack, ProductRack>();
            _container.PerRequest <ISessionRegister, SessionRegister>();
            _container.PerRequest <IShoppingCart, ShoppingCart>();
            _container.PerRequest <IUserStorage, UserStorage>();

            #endregion

            #region ViewModels

            _container.RegisterShellProvider();
            _container.LoadViewModels(Assembly.GetExecutingAssembly());

            #endregion
        }
Exemple #5
0
        public static void AddRegisterOption <T>(this SimpleContainer container) where T : class, new()
        {
            var configuration = container.GetInstance <IConfiguration>();
            var settings      = configuration.GetRegisterSettings <T>();

            container.Handler <IOptions <T> >(_ => new RegisterOptions <T>(settings));
        }
        protected override void Configure()
        {
            if (Execute.InDesignMode)
            {
                return;
            }

            _container = new SimpleContainer();
            _container.Instance(_container);
            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <IEventAggregator, EventAggregator>();

            var       val    = ConfigurationManager.AppSettings["ConnectionUrl"];
            APIConfig config = new APIConfig();

            config.ConnectionUrl  = ConfigurationManager.AppSettings["ConnectionUrl"];
            config.TokensEndPoint = ConfigurationManager.AppSettings["TokensEndPoint"];
            config.ServerEndPoint = ConfigurationManager.AppSettings["ServerEndPoint"];

            string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs");

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.RollingFile(Path.Combine(logsDirectory, "log-{Date}.txt"))
                         .CreateLogger();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(config.ConnectionUrl);

            _container.Handler <APIConfig>(c => config);
            _container.Handler <HttpClient>(c => client);

            _container.PerRequest <ILoginService, LoginClient>();
            _container.PerRequest <IServerService, ServerClient>();

            _container.PerRequest <IShellViewModel, ShellViewModel>();
            _container.PerRequest <ILoginConductorViewModel, LoginConductorViewModel>();
            _container.PerRequest <IContentConductorViewModel, ContentConductorViewModel>();

            _container.PerRequest <ILoginViewModel, LoginViewModel>();
            _container.PerRequest <IMainViewModel, MainViewModel>();
            _container.PerRequest <IHeaderViewModel, HeaderViewModel>();

            _container.PerRequest <ILoginHandler, LoginView>();
        }
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, MetroWindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();

            var baseExperienceData = new ExperienceData() { DisplayName = "Base Experience" };
            var classExperienceData = new ExperienceData() { DisplayName = "Class Experience" };
            IExperienceControl[] baseExperienceControls = GetExperienceControls(baseExperienceData, classExperienceData);

            ExperienceContainer experienceContainer = new ExperienceContainer(baseExperienceData, classExperienceData, baseExperienceControls);

            container.Handler<ShellViewModel>(simpleContainer =>
                                              new ShellViewModel(
                                                  container.GetInstance<SettingsViewModel>(),
                                                  experienceContainer,
                                                  new ExpCardCalculatorViewModel(experienceContainer),
                                                  container.GetInstance<IWindowManager>()));

            // TODO - refactor settings view model to just take a collection of menuitems
            container.Handler<SettingsViewModel>(simpleContainer => new SettingsViewModel(baseExperienceControls));
        }
Exemple #8
0
        protected override void Configure()
        {
            #region DI

            _container = new SimpleContainer();
            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <ICoordinateTranslationService, CoordinatesTranslationService>();
            _container.Singleton <IPdfService, PdfService>();
            _container.Singleton <MenuViewModel>("StaticMenuViewModel");

            _container.Handler <DrawingCanvasViewModel>(c => new DrawingCanvasViewModel(c.GetInstance <IEventAggregator>()));

            _container.Singleton <IOpenFileService, OpenFileService>();
            _container.Singleton <ISaveFileService, SaveFileService>();

            _container.PerRequest <CharacterSheetViewModel>();
            _container.PerRequest <MainViewModel>();

            _container.Handler <FieldFactory>(c => new FieldFactory(
                                                  () => c.GetInstance <MenuViewModel>("StaticMenuViewModel")
                                                  , c.GetInstance <IEventAggregator>()
                                                  )
                                              );

            #endregion

            #region special binding values

            MessageBinder.SpecialValues
            .Add("$imagesize", (ctx) =>
            {
                if (ctx.Source is Image image)
                {
                    var width  = image.ActualWidth;
                    var height = image.ActualHeight;
                    return(width: width, height: height);
                }
Exemple #9
0
        protected override void Configure()
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Information()
                         .WriteTo.File("logs\\log.txt", rollingInterval: RollingInterval.Day)
                         .CreateLogger();

            Log.Information("Application starting.");

            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <IEventAggregator, EventAggregator>();

            var apiConfig  = (Hashtable)ConfigurationManager.GetSection("apiConfig");
            var httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(apiConfig["baseUrl"].ToString());
            _container.Handler <HttpClient>((args) => httpClient);

            _container.PerRequest <ShellViewModel>();
            _container.PerRequest <LoginViewModel>();
            _container.PerRequest <ServersListViewModel>();

            _container.Singleton <IServiceClient, ServiceClient>();
        }
		public void HandlerTest()
		{
			SimpleContainer sc = new SimpleContainer();
			ITest1 t1 = null;
			sc.Handler<ITest1>((i) =>
			{
				Assert.AreEqual(sc, i);
				t1 = new Test1();
				return t1;
			});

			var result1 = sc.GetInstance<ITest1>();
			Assert.IsNotNull(t1);
			Assert.IsNotNull(result1);
			Assert.AreEqual(t1, result1);

			Test2 t2 = null;
			sc.Handler<ITest2, Test2>(i =>
			{
				Assert.AreEqual(sc, i);
				t2 = new Test2();
				return t2;
			});

			var result2 = sc.GetInstance<ITest2>();
			Assert.IsNotNull(t2);
			Assert.IsNotNull(result2);
			Assert.AreEqual(t2, result2);

			result2 = sc.GetInstance<Test2>();
			Assert.IsNotNull(result2);
			Assert.AreEqual(t2, result2);
		}
Exemple #11
0
 public static void RegisterShellProvider(this SimpleContainer simpleContainer)
 {
     simpleContainer.Handler <IShellProvider>(currentContainer => new ShellProvider(currentContainer));
 }
Exemple #12
0
        /// <summary>
        /// Определение DI контейнера приложения и регистрация зависимостей в нём
        /// </summary>
        protected override void Configure()
        {
            container = new SimpleContainer();


            //Root Laundry level things
            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();
            container.Singleton <IModel, DataBaseModel>();

            container.Handler <IScreenFactory>((container) => new ScreenFactory(container));

            container.Singleton <IShell, ShellViewModel>();

            //ViewModels
            container.PerRequest <LoginScreenViewModel>();
            container.Singleton <DashBoardViewModel>();
            container.Singleton <AnalyticsViewModel>();

            container.Singleton <ClientDictionaryViewModel>("ClientDictionary");
            container.PerRequest <ClientEditorViewModel>();
            container.PerRequest <ClientDataGridViewModel>();
            container.Singleton <ClientCardViewModel>();
            container.PerRequest <ClientSearchViewModel>();

            container.Singleton <EmployeeDictionaryViewModel>("EmployeeDictionary");
            container.PerRequest <EmployeeEditorViewModel>();
            container.PerRequest <EmployeeDataGridViewModel>();
            container.Singleton <EmployeeCardViewModel>();

            container.Singleton <SubsidiaryDictionaryViewModel>("SubsidiaryDictionary");
            container.PerRequest <SubsidiaryEditorViewModel>();
            container.PerRequest <SubsidiaryGridViewModel>();
            container.Singleton <SubsidiaryCardViewModel>();

            container.Singleton <CarDictionaryViewModel>("CarDictionary");
            container.PerRequest <CarEditorViewModel>();
            container.PerRequest <CarDataGridViewModel>();
            container.Singleton <CarCardViewModel>();

            container.PerRequest <OrderDictionaryViewModel>("OrderDictionary");
            container.PerRequest <OrderEditorViewModel>();
            container.PerRequest <OrderDataGridViewModel>();
            container.Singleton <OrderCardViewModel>();

            container.Singleton <ClothDataGridViewModel>();
            container.Singleton <ClothKindDictionaryViewModel>();
            container.Singleton <ClothInstanceCardViewModel>();
            container.Singleton <ClothEditorViewModel>();

            container.PerRequest <ClothKindTreeViewModel>()
            .PerRequest <ClothKindCardViewModel>()
            .PerRequest <ClothKindEditorViewModel>();

            container.Singleton <DiscountSystemViewModel>();
            container.Singleton <DiscountGridViewModel>();

            container.Singleton <SettingsViewModel>();
            container.Singleton <AboutViewModel>();

            //Non-screen views like dialog views

            container.PerRequest <PaginatorViewModel>();
            container.Singleton <Visibilities>();
            container.Singleton <DeleteDialogViewModel>();
            container.Singleton <ConnectionLostDialogViewModel>();

            container
            .Singleton <DirectorDashBoardViewModel>()
            .Singleton <AdvisorDashBoardViewModel>()
            .Singleton <WasherDashBoardViewModel>()
            .Singleton <CourierDashBoardViewModel>();
        }