Exemplo n.º 1
0
        public static IAppServiceProvider CreateProvider()
        {
            CreateBaseServiceFactories();
            AppServiceProvider.SetServiceFactoryFunc(typeof(IDataContext), CreateDataContext);
            var factory  = AppServiceProviderFactoryProvider.GetFactory();
            var provider = factory.Create();

            return(provider);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
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>()));
        }