Example #1
0
        public BaseUnitTest()
        {
            AppServiceProvider = new AppServiceProvider();

            ConfigureDataDirectory();
            ConfigureDependencies();
        }
Example #2
0
        public static IAppServiceProvider CreateProvider()
        {
            CreateBaseServiceFactories();
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContext), CreateDataContext);
            var factory  = AppServiceProviderFactoryProvider.GetFactory();
            var provider = factory.Create();

            return(provider);
        }
Example #3
0
        public void BuildServiceProvider_Success()
        {
            //Act
            var action = AppServiceProvider.BuildServiceProvider();

            //Assert
            Assert.Equal(typeof(ServiceProvider), action.GetType());
            Assert.NotNull(action);
        }
Example #4
0
 internal static void MigrateUp(AppOptions options)
 {
     Console.WriteLine("********************Starting to migrate up...");
     Options = options;
     using (Scope = AppServiceProvider.CreateScope())
     {
         MigrationRunner = Scope.ServiceProvider.GetRequiredService <IMigrationRunner>();
         MigrationRunner.MigrateUp();
     }
 }
Example #5
0
        public void GetService_ShouldInvokeUnderlyingServiceProvider()
        {
            var service = new object();

            _serviceProviderMock
            .Setup(x => x.GetService(typeof(object)))
            .Returns(service)
            .Verifiable();

            var appServiceProvider = new AppServiceProvider(_serviceProviderMock.Object);

            var returnedService = appServiceProvider.GetService(typeof(object));

            Assert.That(returnedService, Is.EqualTo(service));
        }
        public static void CreateBaseServiceFactories()
        {
            AppServiceProvider.SetServiceFactoryFunc(typeof(IUserRepository), CreateUserRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IOrgRepository), CreateOrgRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IAttributeRepository), CreateAttributeRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocDefRepository), CreateDocDefRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocRepository), CreateDocRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocStateRepository), CreateDocStateRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocumentTableMapRepository), CreateDocumentTableMapRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IEnumRepository), CreateEnumRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IFormRepository), CreateFormRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ILanguageRepository), CreateLanguageRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IPermissionRepository), CreatePermissionRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IWorkflowRepository), CreateWorkflowRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IWorkflowEngine), CreateWorkflowEngine);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IAttributeStorage), CreateAttributeStorage);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocumentStorage), CreateDocumentStorage);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ITemplateReportGeneratorProvider), CreateTemplateReportGeneratorProvider);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IControlFactory), CreateControlFactory);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IComboBoxEnumProvider), CreateComboBoxEnumProvider);

            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilderFactory), CreateSqlQueryBuilderFactory);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilderFactory), CreateSqlQueryBuilderFactory2);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryReaderFactory), CreateSqlQueryReaderFactory);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryReaderFactory), CreateSqlQueryReaderFactory2);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContextConfigSectionNameProvider), CreateDataContextConfigSectionNameProvider);

            AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContext), CreateDataContext);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IMultiDataContext), CreateDataContext);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilder), CreateSqlQueryBuilder);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilder), CreateSqlQueryBuilder2);

            AppServiceProvider.SetServiceFactoryFunc(typeof(IXlsFormDefBuilderFactory), CreateXlsFormDefBuilderFactory);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IQueryRepository), CreateQueryRepository);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IExternalProcessLauncher), CreateExternalProcessLauncher);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IBuilder <ReportDef, SqlQuery>), CreateSqlQueryFromReportDefBuilder);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IBuilder <ReportDef, XlsDef>), CreateXlsDefFromReportDefBuilder);

            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocDefStateListProvider), CreateMultiContextDocDefStateListProvider);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocDefStateListProvider), CreateDocDefStateListProvider);
        }
Example #7
0
        internal static void Preview(AppOptions options)
        {
            Console.WriteLine("**************** Starting preview mode...");
            Options = options;

            using (Scope = AppServiceProvider.CreateScope())
            {
                MigrationRunner = Scope.ServiceProvider.GetRequiredService <IMigrationRunner>();
                using (var runnerScope = MigrationRunner.BeginScope())
                {
                    try
                    {
                        MigrationRunner.MigrateUp();
                    }
                    finally
                    {
                        runnerScope.Cancel();
                    }
                }
            }
        }
Example #8
0
        // Performs initialization of the XNA types required for the application.
        private void InitializeXnaApplication()
        {
            // Create the service provider
            Services = new AppServiceProvider();

            // Add the SharedGraphicsDeviceManager to the Services as the IGraphicsDeviceService for the app
            foreach (object obj in ApplicationLifetimeObjects)
            {
                if (obj is IGraphicsDeviceService)
                    Services.AddService(typeof(IGraphicsDeviceService), obj);
            }

            // Create the ContentManager so the application can load precompiled assets
            Content = new ContentManager(Services, "Content");

            // Create a GameTimer to pump the XNA FrameworkDispatcher
            FrameworkDispatcherTimer = new GameTimer();
            FrameworkDispatcherTimer.FrameAction += FrameworkDispatcherFrameAction;
            FrameworkDispatcherTimer.Start();
        }
Example #9
0
        private static void CreateBaseServiceFactories()
        {
            AppServiceProvider.SetServiceFactoryFunc(typeof(IUserRepository),
                                                     (arg) =>
            {
                var prov = arg as IAppServiceProvider;
                return(new UserRepository(prov as IAppServiceProvider, prov.Get <IDataContext>()));
            });
            AppServiceProvider.SetServiceFactoryFunc(typeof(IOrgRepository),
                                                     prov =>
                                                     new OrgRepository((prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IAttributeRepository), (prov) => new AttributeRepository(prov as IAppServiceProvider));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocDefRepository),
                                                     prov =>
                                                     new DocDefRepository(prov as IAppServiceProvider, (prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocRepository),
                                                     prov =>
                                                     new DocRepository(prov as IAppServiceProvider, (prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocStateRepository),
                                                     prov =>
                                                     new DocStateRepository((prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocumentTableMapRepository),
                                                     (prov) =>
                                                     new DocumentTableMapRepository((prov as IAppServiceProvider).Get <IDataContext>()));

            AppServiceProvider.SetServiceFactoryFunc(typeof(IEnumRepository),
                                                     (prov) =>
                                                     new EnumRepository(prov as IAppServiceProvider, (prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IFormRepository),
                                                     (prov) =>
                                                     new FormRepository(prov as IAppServiceProvider, (prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(ILanguageRepository),
                                                     prov =>
                                                     new LanguageRepository(prov as IAppServiceProvider,
                                                                            (prov as IAppServiceProvider).Get <IDataContext>()));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IPermissionRepository),
                                                     prov =>
                                                     new PermissionRepository(prov as IAppServiceProvider,
                                                                              (prov as IAppServiceProvider).Get <IDataContext>()));

            //AppServiceProvider.SetServiceFactoryFunc(typeof(IWorkflowRepository), CreateWorkflowRepository);
            //AppServiceProvider.SetServiceFactoryFunc(typeof(IWorkflowEngine), CreateWorkflowEngine);
            AppServiceProvider.SetServiceFactoryFunc(typeof(IAttributeStorage),
                                                     (prov, dc) =>
                                                     new ServiceDefInfo(new AttributeStorage(prov as IAppServiceProvider, dc as IDataContext), true));

            AppServiceProvider.SetServiceFactoryFunc(typeof(IDocumentStorage),
                                                     (prov, dc) =>
                                                     new ServiceDefInfo(new DocumentStorage(prov as IAppServiceProvider, dc as IDataContext), true));

            AppServiceProvider.SetServiceFactoryFunc(typeof(ITemplateReportGeneratorProvider),
                                                     (prov, dc) =>
                                                     new ServiceDefInfo(new TemplateReportGeneratorProvider(prov as IAppServiceProvider, dc as IDataContext), true));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IControlFactory),
                                                     (prov, dc) =>
                                                     new ServiceDefInfo(new ControlFactory(prov as IAppServiceProvider,
                                                                                           dc as IDataContext), false));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IComboBoxEnumProvider),
                                                     prov =>
                                                     new ComboBoxEnumProvider(prov as IAppServiceProvider,
                                                                              (prov as IAppServiceProvider).Get <IDataContext>()));

            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilderFactory),
                                                     prov =>
                                                     new SqlQueryBuilderFactory(prov as IAppServiceProvider,
                                                                                (prov as IAppServiceProvider).Get <IDataContext>()));

            //AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilderFactory), CreateSqlQueryBuilderFactory2);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryReaderFactory),
                                                     prov => new SqlQueryReaderFactory(prov as IAppServiceProvider,
                                                                                       (prov as IAppServiceProvider).Get <IDataContext>()));

            //AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryReaderFactory), CreateSqlQueryReaderFactory2);
            //AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContextConfigSectionNameProvider), CreateDataContextConfigSectionNameProvider);

            //AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContext), CreateDataContext);
            //AppServiceProvider.SetServiceFactoryFunc(typeof(IMultiDataContext), CreateDataContext);
            AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilder),
                                                     prov =>
                                                     new SqlQueryBuilderTool(prov as IAppServiceProvider,
                                                                             (prov as IAppServiceProvider).Get <IDataContext>()));
            //AppServiceProvider.SetServiceFactoryFunc(typeof(ISqlQueryBuilder), CreateSqlQueryBuilder2);

            AppServiceProvider.SetServiceFactoryFunc(typeof(IXlsFormDefBuilderFactory),
                                                     (prov) => new XlsFormDefBuilderFactory(prov as IAppServiceProvider));
            AppServiceProvider.SetServiceFactoryFunc(typeof(IQueryRepository),
                                                     (prov) => new QueryRepository(prov as IAppServiceProvider, (prov as IAppServiceProvider).Get <IDataContext>()));
        }
Example #10
0
 private static async Task<AppViewModel> CreateAppViewModel()
 {
     var serviceProvider = new AppServiceProvider();
     await serviceProvider.InitializeAsync();
     var result = new AppViewModel(serviceProvider);
     return result;
 }
Example #11
0
 public void Setup()
 {
     _appServiceProvider = new AppServiceProvider();
 }