protected override (Stream clientOutput, Stream serverInput) SetupServer() { var clientPipe = new Pipe(TestOptions.DefaultPipeOptions); var serverPipe = new Pipe(TestOptions.DefaultPipeOptions); _host = new LanguageServerHost( clientPipe.Reader.AsStream(), serverPipe.Writer.AsStream(), options => options .ConfigureLogging(x => x.AddLanguageProtocolLogging()) .WithServices(services => { services.AddSingleton(_loggerFactory); }) .OnInitialize((server, request, token) => { var configBuilder = new Microsoft.Extensions.Configuration.ConfigurationBuilder() .AddConfiguration(server.Configuration.GetSection("csharp")) .AddConfiguration(server.Configuration.GetSection("omnisharp")); if (_setupConfiguration != null) configBuilder.AddConfiguration(_setupConfiguration); var config = configBuilder.Build(); OmniSharpTestHost = CreateOmniSharpHost(config, new LanguageServerEventEmitter(server)); var handlers = LanguageServerHost.ConfigureCompositionHost(server, OmniSharpTestHost.CompositionHost); _host.UnderTest(OmniSharpTestHost.ServiceProvider, OmniSharpTestHost.CompositionHost); LanguageServerHost.RegisterHandlers(server, OmniSharpTestHost.CompositionHost, handlers); return Task.CompletedTask; }), CancellationTokenSource.CreateLinkedTokenSource(CancellationToken) ); startUpTask = _host.Start(); return (serverPipe.Reader.AsStream(), clientPipe.Writer.AsStream()); }
/// <summary> /// Build the configuration and populate the service collection based on the input environment. /// </summary> private (IConfigurationRoot Configuration, ServicesBuilder ServicesBuilder) Init() { var configurationOptions = this.GetOrAdd(() => new ConfigurationOptions()); var configurationBuilder = new ConfigurationBuilder() .SetFileProvider(_environment.ContentRootFileProvider) .Apply(configurationOptions.ApplicationConfiguration) .Apply(configurationOptions.EnvironmentConfiguration, _environment.EnvironmentName) .Apply(configurationOptions.EnvironmentConfiguration, "local"); #pragma warning disable CA2000 var cb = new Extensions.Configuration.ConfigurationBuilder( Scanner, _environment, new ConfigurationRoot(new List <IConfigurationProvider>()), configurationBuilder, _logger, ServiceProperties ); #pragma warning restore CA2000 var configuration = configurationBuilder .AddConfiguration(cb.Build()) .Build(); var serviceCollection = new ServiceCollection(); var servicesBuilder = new ServicesBuilder( Scanner, AssemblyProvider, AssemblyCandidateFinder, serviceCollection, configuration, _environment, _logger, ServiceProperties ); servicesBuilder.Services.AddLogging( builder => { builder.ClearProviders(); builder.Services.AddSingleton(_loggerFactory); } ); Composer.Register( servicesBuilder.Scanner, servicesBuilder, typeof(IServiceConvention), typeof(ServiceConventionDelegate) ); return(configuration, servicesBuilder); }
public Startup(IHostingEnvironment env) { // Set up configuration sources. var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); if (env.Configuration != null) { // This allows passing of config values via the cmd line, e.g.: dnx web --app.EnableDbTests=true builder.AddConfiguration("app.", env.Configuration); } Configuration = builder.Build(); Configuration.Bind(StartupOptions); }
private IConfiguration SetupConfiguration() { var existingConfiguration = Builder.Services.First(z => z.ServiceType == typeof(IConfiguration)) .ImplementationInstance as IConfiguration; var configurationBuilder = new MsftConfigurationBinder(); configurationBuilder.AddConfiguration(existingConfiguration); configurationBuilder .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddYamlFile("appsettings.yml", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{_environment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddYamlFile($"appsettings.{_environment.EnvironmentName}.yml", optional: true, reloadOnChange: true); var cb = new ConfigurationBuilder( Scanner, _environment, existingConfiguration, configurationBuilder, _logger, Properties); cb.Build(); if (_environment.IsDevelopment() && !string.IsNullOrEmpty(_environment.ApplicationName)) { var appAssembly = Assembly.Load(new AssemblyName(_environment.ApplicationName)); if (appAssembly != null) { configurationBuilder.AddUserSecrets(appAssembly, optional: true); } } configurationBuilder.AddEnvironmentVariables(); var newConfig = configurationBuilder.Build(); Builder.Services.Replace(ServiceDescriptor.Singleton <IConfiguration>(newConfig)); return(newConfig); }
public Startup(IConfiguration configuration) { // Configuration = configuration; var builder = new ConfigurationBuilder().AddConfiguration(configuration); /* Add Default configurations */ builder.AddConfiguration(configuration); /* Add Custom configurations */ // adding cache.json which contains cachemanager configuration(s) var appOptions = configuration.GetSection(nameof(AppOptions)).Get <AppOptions>(); if (true || appOptions.Cache) { builder.AddJsonFile("cache.json"); } Configuration = builder.Build(); /* * // For manual for like console app. * var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder().AddJsonFile("cache.json"); * Configuration = builder.Build(); * * // var cacheConfiguration = Configuration.GetCacheConfiguration(); * var cacheConfiguration = * Configuration.GetCacheConfiguration("retaileasy_cache") * .Builder * .WithMicrosoftLogging(f => * { * f.AddSerilog(); * // f.AddDebug(LogLevel.Information); * }) * .Build(); */ SetupLogging(Configuration); }
private static IConfigurationRoot CreateConfiguration(IConfiguration configurationData) { var builder = new ConfigurationBuilder(); if (configurationData != null) { builder.AddConfiguration(configurationData); } // We need to set the "UseLegacySdkResolver" for tests because // MSBuild's SDK resolver will not be able to locate the .NET Core SDKs // that we install locally in the ".dotnet" directory. // This property will cause the MSBuild project loader to set the // MSBuildSDKsPath environment variable to the correct path "Sdks" folder // within the appropriate .NET Core SDK. var msbuildProperties = new Dictionary <string, string>() { [$"MSBuild:{nameof(MSBuildOptions.UseLegacySdkResolver)}"] = "true" }; builder.AddInMemoryCollection(msbuildProperties); return(builder.Build()); }