protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Rebind <IMetricsInitializer>().To <MetricsInitializerFake>().InSingletonScope(); kernel.Rebind <IDiscoverySourceLoader>().To <AlwaysLocalHost>().InSingletonScope(); action?.Invoke(kernel); kernel.Bind <ISlowService>().To <SlowService>().InSingletonScope(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { Kernel = kernel; kernel.Rebind <ServiceValidator>().To <MockServiceValidator>().InSingletonScope(); kernel.Rebind <ICertificateLocator>().To <DummyCertificateLocator>().InSingletonScope(); kernel.Bind <ICalculatorService>().To <CalculatorService>().InSingletonScope(); }
protected int GetBasePortFromHttpServiceAttribute() { var commonConfig = new BaseCommonConfig(); var mapper = new OrleansServiceInterfaceMapper(new AssemblyProvider(new ApplicationDirectoryProvider(commonConfig), commonConfig, new ConsoleLog())); var basePort = mapper.ServiceInterfaceTypes.First().GetCustomAttribute <HttpServiceAttribute>().BasePort; return(basePort); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <TimeRecord, TimeRecordEntity>(); cfg.CreateMap <TimeRecordEntity, TimeRecord>(); }); kernel.Bind <IMapper>().ToMethod(x => config.CreateMapper()).InSingletonScope(); kernel.Bind <IConfiguration>().ToConstant(_configuration); kernel.Bind <IReportService>().To <ReportService>(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <User, UserEntity>() .ForMember(destination => destination.SocialProfiles, opts => opts.MapFrom(source => string.Join(" | ", source.SocialProfiles))); cfg.CreateMap <UserEntity, User>() .ForMember(destination => destination.SocialProfiles, opts => opts.MapFrom(source => source.SocialProfiles.Split(" | ", StringSplitOptions.RemoveEmptyEntries))); }); kernel.Bind <IMapper>().ToMethod(x => config.CreateMapper()).InSingletonScope(); kernel.Bind <IConfiguration>().ToConstant(_configuration); kernel.Bind <IAuthService>().To <AuthService>(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Rebind <ILog>().ToConstant(new ConsoleLog()); kernel.Rebind <IConfigurationDataWatcher, ManualConfigurationEvents>() .To <ManualConfigurationEvents>() .InSingletonScope(); kernel.Rebind <IEventPublisher>().To <NullEventPublisher>(); kernel.Rebind <IWorker>().To <WaitingWorker>(); kernel.Rebind <IMetricsInitializer>().To <MetricsInitializerFake>().InSingletonScope(); kernel.Bind <T>().ToConstant(Substitute.For <T>()); Instance = kernel.Get <T>(); }
protected virtual ServiceArguments GetServiceArguments(int?basePortOverride, bool isSecondary, int?shutdownWaitTime, ServiceStartupMode startupMode = ServiceStartupMode.CommandLineNonInteractive) { if (isSecondary && basePortOverride == null) { throw new ArgumentException("You must specify a basePortOverride when running a secondary silo."); } var siloClusterMode = isSecondary ? SiloClusterMode.SecondaryNode : SiloClusterMode.PrimaryNode; ServiceArguments arguments = new ServiceArguments(startupMode, basePortOverride: basePortOverride, siloClusterMode: siloClusterMode, shutdownWaitTimeSec: shutdownWaitTime); if (basePortOverride != null) { return(arguments); } var commonConfig = new BaseCommonConfig(); var mapper = new OrleansServiceInterfaceMapper(new AssemblyProvider(new ApplicationDirectoryProvider(commonConfig), commonConfig, Log)); var basePort = mapper.ServiceInterfaceTypes.First().GetCustomAttribute <HttpServiceAttribute>().BasePort; return(new ServiceArguments(startupMode, basePortOverride: basePort, shutdownWaitTimeSec: shutdownWaitTime)); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Bind <ISlowService>().To <SlowService>().InSingletonScope(); kernel.RebindForTests(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { // throw new System.NotImplementedException(); }
/// <summary> /// When overridden, allows a service to configure its Ninject bindings and infrastructure features. Called /// after infrastructure was binded but before the silo is started. You must bind an implementation to the /// interface defined by <see cref="TInterface"/>. /// </summary> /// <param name="kernel">A <see cref="IKernel"/> already configured with infrastructure bindings.</param> /// <param name="commonConfig">An <see cref="BaseCommonConfig"/> that allows you to select which /// infrastructure features you'd like to enable.</param> protected abstract void Configure(IKernel kernel, BaseCommonConfig commonConfig);
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Bind <ICalculatorService>().To <CalculatorService>(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Rebind <IMetricsInitializer>().To <MetricsInitializerFake>().InSingletonScope(); kernel.Rebind <IDiscovery>().To <AlwaysLocalhostDiscovery>().InSingletonScope(); kernel.Rebind <IDiscoverySourceLoader>().To <AlwaysLocalHost>().InSingletonScope(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Rebind <TFake>().ToConstant(_fake); kernel.Rebind <IEventPublisher <CrashEvent> >().ToConstant(Substitute.For <IEventPublisher <CrashEvent> >()); kernel.Rebind <IMetricsInitializer>().ToConstant(Substitute.For <IMetricsInitializer>()); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Bind <ICalculatorService>().To <CalculatorService>(); kernel.Bind <ServiceValidator>().To <MockServiceValidator>().InSingletonScope(); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { base.Configure(kernel, commonConfig); kernel.Rebind <Func <MicrodotHostingConfig> >().ToMethod(_ => () => MicrodotHostingConfigMock); }
protected override void Configure(IKernel kernel, BaseCommonConfig commonConfig) { kernel.Bind <IGpuService>().To <GpuService>(); kernel.Get <ILog>().Error("tresint 123"); }