public static async Task <LocalWorkService> Create(IDictionary <string, string> configuration) { var host = new LocalServiceHost( new NuGetStartOptions() { AppDescription = new ServiceHostDescription( new ServiceHostInstanceName( new ServiceHostName( new DatacenterName( new EnvironmentName( "nuget", "local"), 0), "work"), 0), Environment.MachineName), Configuration = configuration, Services = new[] { "LocalWork" } }); var name = new ServiceName(host.Description.InstanceName, ServiceDefinition.FromType <WorkService>().Name); host.Initialize(); if (!await host.Start()) { throw new InvalidOperationException(Strings.LocalWorker_FailedToStart); } return(host.GetInstance <LocalWorkService>()); }
protected internal override IEnumerable <ServiceDefinition> GetServices() { yield return(ServiceDefinition.FromType <T>()); }