// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddControllersAsServices(); //把控制器当作服务注册 return(CoreContainer.Init(services)); }
public void Init(WindsorContainer windsor) { try { if (CoreContainer.Initialized) { return; } CoreContainer.SetUp(windsor); //SqlRepoSqlServerCastleInstaller.Load( CoreContainer.Container); //var connectionProvider = new AppSettingsConnectionProvider(); //containerBuilder.RegisterInstance(connectionProvider) // .As<IMsSqlConnectionProvider>(); //CoreContainer.Container.Register(Component.For<ISqlLogger>().ImplementedBy<CustomSqlLogger>()); CoreContainer.Container.Register(Component.For <ISqlLogWriter>().ImplementedBy <ConsoleSqlLogger>()); CoreContainer.Container.Register(Component.For <ISqlLogWriter>().ImplementedBy <NoOpSqlLogger>()); CoreContainer.Container.Register(Component.For <IRepositoryFactory>().ImplementedBy <RepositoryFactory>()); CoreContainer.Container.Register(Component.For <IStatementFactoryProvider>().ImplementedBy <MsSqlStatementFactoryProvider>()); CoreContainer.Container.Register(Component.For <IStatementFactory>().ImplementedBy <StatementFactory>()); CoreContainer.Container.Register(Component.For <IEntityMapper>().ImplementedBy <DapperEntityMapper>()); CoreContainer.Container.Register(Component.For <IStatementExecutor>().ImplementedBy <DapperStatementExecutor>()); CoreContainer.Container.Register(Component.For <IWritablePropertyMatcher>().ImplementedBy <WritablePropertyMatcher>()); CoreContainer.Container.Register(Component.For <IRepositoryFactory>().ImplementedBy <IRepositoryFactory>()); // CoreContainer.Container.Register(Component.For<ISqlLogger>().ImplementedBy<CustomSqlLogger>()); } catch (Exception ex) { throw; } }
public void Init() { try { CoreContainer.SetUp(new WindsorContainer()); CoreContainer.Container.Register(Component.For <IIranMarketerDatabase>().ImplementedBy <IranMarketerDatabase>()); CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <IranMarketerSession>()); FromAssemblyDescriptor fromAssemblyInDirectoryUserManagement = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.UserManagement.dll")); CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(IService <,>)).WithService.DefaultInterfaces()); CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(IRepository <,>)).WithService.AllInterfaces()); CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(BaseMapper <>)).WithServiceBase().WithServiceSelf().LifestyleTransient()); FromAssemblyDescriptor fromAssemblyInDirectoryApi = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.API.dll")); CoreContainer.Container.Register(fromAssemblyInDirectoryApi.BasedOn(typeof(AbstractProvider <, ,>)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient()); FromAssemblyDescriptor fromAssemblyInDirectoryApiBasic = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.API.dll")); CoreContainer.Container.Register(fromAssemblyInDirectoryApi.BasedOn(typeof(BaseProvider)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient()); FromAssemblyDescriptor fromAssemblyInDirectorySetting = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.Service.dll")); CoreContainer.Container.Register(fromAssemblyInDirectorySetting.BasedOn(typeof(BaseSettingService)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient()); } catch (Exception ex) { throw ex; } }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddControllers() .AddControllersAsServices(); //把控制器当作服务注册 return(CoreContainer.Init(services)); }
static void Main(string[] args) { CoreContainer.SetUp(new WindsorContainer()); //CoreContainer.Container.Register(Component.For<INewRepository>().ImplementedBy<NewRepository>()); //CoreContainer.Container.Register(Component.For<IWorldRepository>().ImplementedBy<WorldRepository>()); //CoreContainer.Container.Register(Component.For<ITestSession>().ImplementedBy<TestSession>()); CoreContainer.Container.Register(Component.For <IMyDatabaseSettings>().ImplementedBy <MyDatabaseSettings>()); CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <TestSession>()); SharedDataTest sharedDataTest = new SharedDataTest(); var x = sharedDataTest.GetSectors(); int a = 0; }
protected override void ConfigureWebHost(IWebHostBuilder builder) { Runner = MongoDbRunner.Start(); builder.ConfigureServices(services => { var client = new MongoClient(Runner.ConnectionString); var database = client.GetDatabase("okn"); services.AddSingleton(database); CoreContainer.Init(services); }); }
private IWebHost BuildWebHost() { var container = new CoreContainer { mcore = this }; var mservice = new ServiceDescriptor(container.GetType(), container); return(WebHost.CreateDefaultBuilder(new string[0]) .UseStartup <Startup>() .ConfigureServices(x => x.Add(mservice)) .UseUrls("http://0.0.0.0:6969") .Build()); }
static void Main(string[] args) { CoreContainer.SetUp(new WindsorContainer()); //CoreContainer.Container.Register(Component.For<INewRepository>().ImplementedBy<NewRepository>()); //CoreContainer.Container.Register(Component.For<IWorldRepository>().ImplementedBy<WorldRepository>()); //CoreContainer.Container.Register(Component.For<ITestSession>().ImplementedBy<TestSession>()); CoreContainer.Container.Register(Component.For <IMyDatabaseSettings>().ImplementedBy <MyDatabaseSettings>()); CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <TestSession>()); TestClass2 class2 = new TestClass2(); //TestClass.Test(); class2.GetTest(); }
/// <summary> /// Main Task Runner /// </summary> static void TaskRunner(ConfigurationDto objConfiguration) { IExecutionable objPlayer = null; if (!object.ReferenceEquals(objConfiguration, null)) { objPlayer = new CoreContainer().GetAnyInstance <IExecutionable>(); if (!object.ReferenceEquals(objPlayer, null)) { LogAndConsoleTracker.RegisterLogFacade("Starting Executing features and functions that are enabled... \n", transversal.dto.Enums.Nlog.EnumNLogStruct.TypeOfRegister.All, transversal.dto.Enums.Nlog.EnumNLogStruct.LogType.Info, false); } } }
protected override void ConfigureWebHost(IWebHostBuilder builder) { Runner = MongoDbRunner.Start(); builder.ConfigureServices(services => { var client = new MongoClient(Runner.ConnectionString); var database = client.GetDatabase("okn"); services.AddSingleton(database); CoreContainer.Init(services); services.AddAuthentication("Test") .AddScheme <AuthenticationSchemeOptions, FakeAuthHandler>("Test", options => { }); }); }
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); services.AddMemoryCache(); services.AddAuthentication(OldsaratovAuthenticationDefaults.AuthenticationScheme).AddOldsaratov(options => { options.TokenExpirationTimeout = TimeSpan.FromSeconds(3600); }); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.AddMvc().AddNewtonsoftJson(); ConfigureMongo(services); services.AddTransient <DbContext>(); var v = Assembly.GetEntryAssembly().GetName().Version; var b = Configuration.GetValue <string>("BuildNumber"); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = $"OKN API", Version = v.ToString(), Description = $"Build Number: {b}" }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); CoreContainer.Init(services); }
public void InitIoC() { CoreContainer.Initialize(new BootstrapperSettings(typeof(DoozestanDbContext), ORMFrameWork.EntityFrameWok, Platform.Win)); CoreContainer.Container.Register(Component.For <IConnectionProvider>().ImplementedBy <DefaultDatabaseConnectionProvider>() .Named(DefaultDatabaseConnectionProvider.ConnectionStringName) .LifestylePerThread().IsDefault()); //database CoreContainer.Container.Register(Component.For <CustomDatabase>().ImplementedBy <CustomDatabase>().LifeStyle.Singleton); //common service //FromAssemblyDescriptor fromAssemblyInDirectoryAggregator = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.InternalService.dll")); ////container.Register(fromAssemblyInDirectoryAggregator.BasedOn(typeof(BaseAggregator<>)).WithService.DefaultInterfaces()); //CoreContainer.Container.Install(FromAssembly.InDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.InternalServices.dll"))); //DependencyResolver.SetResolver(new WindsorDependencyResolver(CoreContainer.Container)); FromAssemblyDescriptor fromAssemblyInDirectory = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.InternalService.dll")); CoreContainer.Container.Register(fromAssemblyInDirectory.BasedOn(typeof(IService <>)).WithService.AllInterfaces()); CoreContainer.Container.Install(FromAssembly.InDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.Common.dll"))); FromAssemblyDescriptor fromAssemblyInDirectory2 = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.UserManagement.dll")); CoreContainer.Container.Register(fromAssemblyInDirectory2.BasedOn(typeof(IService <>)).WithService.DefaultInterfaces()); CoreContainer.Container.Register(fromAssemblyInDirectory2.BasedOn(typeof(IDao <>)).WithService.AllInterfaces()); CoreContainer.Container.Register(fromAssemblyInDirectory2.BasedOn(typeof(ClassMapping <>)).WithService.Select(new[] { typeof(IEntitySqlsMapper) })); //Base Mappers should not be Singletone because of renaming ColumnPrefix CoreContainer.Container.Register(fromAssemblyInDirectory2.BasedOn(typeof(BaseMapper <>)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient()); //var assemblyDescriptor = Classes.FromThisAssembly(); //CoreContainer.Container.Register(assemblyDescriptor.BasedOn<IController>().WithServiceSelf().LifestyleTransient()); //ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(CoreContainer.Container.Kernel)); //helpers CoreContainer.Container.Register(Component.For <TransactionHelper>().ImplementedBy <TransactionHelper>()); }
private IHost BuildWebHost() { var container = new CoreContainer { mcore = this }; var mservice = new ServiceDescriptor(container.GetType(), container); return(new HostBuilder() .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureWebHostDefaults(webBuilder => { webBuilder.ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile( "appconfig.json", optional: false, reloadOnChange: false); }); webBuilder.UseStartup <Startup>() .ConfigureServices(x => x.Add(mservice)) .UseUrls("http://0.0.0.0:6969"); }) .Build()); }
public ApiController(CoreContainer cont) { this.core = cont.mcore; }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); return(CoreContainer.Init(services)); }
public MainSection(CoreContainer container) { Container = container; Children.Add("Hello world!"); }