public void importing_services() { var builder1 = new ServiceBuilder(); var builder2 = new ServiceBuilder(); builder1.Add(() => "blue"); builder2.Add(() => "green"); builder2.Add(() => 1); builder2.FillInto(builder1); builder1.Build<string>().ShouldEqual("blue"); // not replaced builder1.Build<int>().ShouldEqual(1); // was filled in }
public void importing_services() { var builder1 = new ServiceBuilder(); var builder2 = new ServiceBuilder(); builder1.Add(() => "blue"); builder2.Add(() => "green"); builder2.Add(() => 1); builder2.FillInto(builder1); builder1.Build <string>().ShouldEqual("blue"); // not replaced builder1.Build <int>().ShouldEqual(1); // was filled in }
private static void Run <T>(ServiceBuilder <T> builder, Action <HostConfigurator> config) where T : class, ServiceControl { var tuple = builder.Build(); HostFactory.Run( host => { // recovery host.EnableServiceRecovery( recovery => { recovery.RestartService(0); recovery.SetResetPeriod(1); }); // common dependecies. host.DependsOn("RabbitMQ"); // control host.UseUnityContainer(tuple.Item1); host.Service <T>( s => { s.ConstructUsingUnityContainer(); s.WhenStarted((service, control) => service.Start(control)); s.WhenStopped((service, control) => service.Stop(control)); }); config(host); }); }
public static async Task Main(string[] args) { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .Build(); var builder = new ServiceBuilder(); builder.Configure <GatewayConfiguration>((config) => { configuration.GetSection("Gateway").Bind(config); }); builder.AddDefaultServices(); builder.AddGatewayServices(); builder.AddLog(configuration); builder.Build(); await builder.RunGatewayAsync(); while (true) { await Task.Delay(1000).ConfigureAwait(false); } }
public override Host Build() { if (ServiceBuilders.Count > 1) { throw new HostConfigurationException("A shelf can only have one service configured"); } ServiceBuilder builder = ServiceBuilders.Single(); _log.DebugFormat("[Shelf:{0}] Building Service: {1}", Description.Name, builder.Name); var controllerFactory = new ServiceControllerFactory(); ActorFactory <IServiceController> factory = controllerFactory.CreateFactory(inbox => { var publish = new PublishChannel(_channel, inbox); IServiceController service = builder.Build(inbox, publish); return(service); }); ActorRef instance = factory.GetActor(); _channel.Connect(x => x.AddChannel(instance)); // this creates the state machine instance in the shelf and tells the servicecontroller // to create the service instance.Send(new CreateService(Description.Name)); return(new ShelfHost(instance)); }
protected override void InitializeCore() { regexNode = new MyRegexTestNode(); ApplicationNode.AddNode(regexNode); emailInfo = regexNode.GetType().GetProperty("Email"); serviceProvider = ServiceBuilder.Build(); hierarchy = new ConfigurationUIHierarchy(ApplicationNode, serviceProvider); }
/// <summary> /// Runs the service. /// </summary> /// <typeparam name="T">The type of the service to run.</typeparam> /// <param name="configureService">An action used to configure the service environment.</param> /// <param name="configureHost">An action used to configure the service host.</param> public static void Run <T>(Action <ServiceBuilder <T> > configureService, Action <HostConfigurator> configureHost) where T : class, ServiceControl { var builder = new ServiceBuilder <T>(); configureService(builder); builder.Build(); Run(builder, configureHost); }
bool exec(Action <ServiceBuilder> action) { using ServiceBuilder builder = new ServiceBuilder(); action(builder); return(new SingleInstanceChecker() .Check(builder.Build())); }
protected override void InitializeCore() { requiredNode = new MyRequiredTestNode(); ApplicationNode.AddNode(requiredNode); valueInfo1 = requiredNode.GetType().GetProperty("Value1"); valueInfo2 = requiredNode.GetType().GetProperty("Value2"); serviceProvider = ServiceBuilder.Build(); hierarchy = new ConfigurationUIHierarchy(ApplicationNode, serviceProvider); }
public void Build() { foreach (var tableName in tableNames) { var repositoryBuilder = new ServiceBuilder(tableName, namespaceStr); var persistence = new Persistence(tableName, PersistenceEnumType.Service); persistence.FlushToDisk(repositoryBuilder.Build()); } }
private static void Init() { if (Interlocked.CompareExchange(ref _initialized, 1, 0) != 0) { return; } Service = ServiceBuilder.Build <TBusiness>(); }
protected override void InitializeCore() { ConfigurationApplicationNode appNode = new ConfigurationApplicationNode(); typeNode = new MyTypeTestNode(); valueInfo1 = typeNode.GetType().GetProperty("TypeName"); serviceProvider = ServiceBuilder.Build(); appNode.AddNode(typeNode); hierarchy = new ConfigurationUIHierarchy(appNode, serviceProvider); }
public static void Init() { if (Interlocked.CompareExchange(ref _initialized, 1, 0) != 0) { return; } Services = ServiceBuilder.Build(); OnGenerationCompleted?.Invoke(null, Services); }
protected override void InitializeCore() { ConfigurationApplicationNode appNode = new ConfigurationApplicationNode(); minLengthNode = new MyMinLengthTestNode(); appNode.AddNode(minLengthNode); valueInfo1 = minLengthNode.GetType().GetProperty("Value1"); valueInfo2 = minLengthNode.GetType().GetProperty("Value2"); serviceProvider = ServiceBuilder.Build(); hierarchy = new ConfigurationUIHierarchy(appNode, serviceProvider); }
public void Create(ServiceBuilderFactory serviceBuilderFactory, HostSettings settings, HostLoggerConfigurator loggerConfigurator) { AppDomain.CurrentDomain.UnhandledException += CatchUnhandledException; HostLogger.UseLogger(loggerConfigurator); ServiceBuilder serviceBuilder = serviceBuilderFactory(settings); _serviceHandle = serviceBuilder.Build(settings); }
public void fill_into_will_not_overwrite_the_parent_if_it_exists() { var services1 = new ServiceBuilder(); var services2 = new ServiceBuilder(); services1.Add<IChrome>(() => new AChrome()); services2.Add<IChrome>(() => new BChrome()); services2.FillInto(services1); services1.Build<IChrome>().ShouldBeOfType<AChrome>(); }
public void fill_into_will_not_overwrite_the_parent_if_it_exists() { var services1 = new ServiceBuilder(); var services2 = new ServiceBuilder(); services1.Add <IChrome>(() => new AChrome()); services2.Add <IChrome>(() => new BChrome()); services2.FillInto(services1); services1.Build <IChrome>().ShouldBeType <AChrome>(); }
public void GetPolicyService_FullName() { var options = new Options() { Url = "reporting.company.com", LogPath = "C:\\" }; var serviceBuilder = new ServiceBuilder(); serviceBuilder.Setup(options); serviceBuilder.Build(); var service = serviceBuilder.GetPolicyService(); Assert.That(service, Is.TypeOf <PolicyService>()); Assert.That(service, Is.Not.Null); }
public void Init() { _logger.LogInformation("Initializing Service Manager..."); if (_initialized) { throw new InvalidOperationException("Service manager was already initialized."); } foreach (var serviceOptions in _servicesOptions.Value) { var service = _serviceBuilder.Build(serviceOptions.Name, serviceOptions.Directory, serviceOptions.FileName, serviceOptions.Arguments, serviceOptions.Url, serviceOptions.SharedShell); _services.Add(service); } _initialized = true; _logger.LogInformation($"Initialized Service Manager. Services:{Environment.NewLine}" + $"{string.Join(Environment.NewLine, _services.Select(s => $"'{s.Name}', URL: '{s.Url}'"))}"); }
public ServiceCore() { LocalLogger.Trace("Initializing ServiceCore."); var serviceCollection = new ServiceCollection(); LocalLogger.Trace("Building service provider."); serviceCollection.BuildServiceProvider(); var builder = new ServiceBuilder(); LocalLogger.Trace("Building services."); builder.Build(serviceCollection); this.ServiceProvider = serviceCollection.BuildServiceProvider(true); LocalLogger.Trace("Building composition context."); var context = new CompositionContext(ServiceProvider.CreateScope().ServiceProvider); LocalLogger.Trace("Composing jobs."); this.Jobs = new List <JobBase>(ComposeJobs(context)); LocalLogger.Info("ServiceCore initialized."); }
public static string GenerateSwaggerFile() { string path = GetAllPaths().Where(p => !SwaggerFiles.Keys.Contains(p)).Single(); SwaggerSchema service = ServiceBuilder.Build("/"); service.Info = Info; service.SecurityDefinitions = SecurityDefinitions; string swagger = Serializer.Process(service); if (SwaggerFiles.ContainsKey(path) == false) { SwaggerFiles.Add(path, swagger); } return(JsonConvert.SerializeObject(service, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); }
public Host Build(ServiceBuilder serviceBuilder) { ServiceHandle serviceHandle = serviceBuilder.Build(this._Settings); return(this.CreateHost(serviceHandle)); }
public void Configuration(IAppBuilder app) { IServiceBuilder builder = new ServiceBuilder(); IServiceCollection services = builder.Build(); }
public virtual Host Build(ServiceBuilder serviceBuilder) { ServiceHandle serviceHandle = serviceBuilder.Build(settings); return(CreateHost(serviceHandle)); }
public Host Build(ServiceBuilder serviceBuilder) { _host._serviceHandle = serviceBuilder.Build(_settings); return(_host); }
public virtual Host Build(ServiceBuilder serviceBuilder) { return(CreateHost(serviceBuilder.Build(Settings))); }
public ConfigurationMergeTool(string mainConfigurationFile, string configurationMergeFile) { this.mainConfigurationFile = mainConfigurationFile; this.configurationMergeFile = configurationMergeFile; serviceContainer = ServiceBuilder.Build(); }