protected override Task <EndpointConfiguration> OnGetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizationConfiguration, Action <EndpointConfiguration> configurationBuilderCustomization) { var factory = new ConfigurationFactory(); return(Task.FromResult(factory.CreateConfiguration())); }
/// <summary> /// Configures a call to a faked object. /// </summary> /// <typeparam name="T">The type of member on the faked object to configure.</typeparam> /// <param name="callSpecification">An expression where the configured memeber is called.</param> /// <returns>A configuration object.</returns> public static IReturnValueArgumentValidationConfiguration <T> CallTo <T>(Expression <Func <T> > callSpecification) { Guard.IsNotNull(callSpecification, "callSpecification"); var fakeObject = GetFakeObjectMethodIsCalledOn(callSpecification); var rule = CreateRuleFromCallSpecification(callSpecification); fakeObject.AddRule(rule); return(ConfigurationFactory.CreateConfiguration <T>(fakeObject, rule)); }
public SheepItDbContext CreateDbContext(string[] args) { var configuration = ConfigurationFactory.CreateConfiguration(args); var connectionString = configuration.GetConnectionString(SheepItDbContext.ConnectionStringName); var optionsBuilder = new DbContextOptionsBuilder <SheepItDbContext>(); optionsBuilder.UseNpgsql(connectionString, opts => opts .CommandTimeout((int)TimeSpan.FromMinutes(10).TotalSeconds) ); return(new SheepItDbContext(optionsBuilder.Options)); }
public Common.Configuration.SimulatorConfiguration GetConfiguration(string id) { ConfigurationFactory factory = _configurations.Where(C => C.Id == id).FirstOrDefault(); if (factory == null) { return(null); } else { return(factory.CreateConfiguration()); } }
public static void Main(string[] args) { var configuration = ConfigurationFactory.CreateConfiguration(args); Log.Logger = LoggerFactory.CreateLogger(configuration); try { var hostBuilder = Host .CreateDefaultBuilder(args) .UseSerilog() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseContentRoot(Directory.GetCurrentDirectory()); webBuilder.UseStartup <Startup>(); }); hostBuilder.ConfigureAppConfiguration((hostingContext, config) => { config.AddOperatingSystemJsonFile(); config.AddEnvironmentJsonFile(); }); var host = hostBuilder.Build(); Log.Information("Starting web host"); host.Run(); } catch (Exception exception) { Log.Fatal(exception, "Terminated unexpectedly!"); Console.WriteLine("Terminated unexpectedly!"); Console.Error.WriteLine(exception.ToString()); throw; } finally { Log.CloseAndFlush(); } }
/// <summary> /// Should be called at the very start of your application to configure and setup /// the Dna Framework /// </summary> /// <param name="configure">The action to add custom configurations to the configuration builder</param> /// <param name="injection">The action to inject services into the service collection</param> public static void Startup(Action <IConfigurationBuilder> configure = null, Action <IContainer, IConfiguration> injection = null) { // Process passed in module list IoC = new Container(); // Load internal based modules // This step is required as they contain information which are used from this point on IoC.Register <IFrameworkEnvironment, FrameworkEnvironment>(Reuse.Singleton); var configBuilder = ConfigurationBuilder(); // Let custom configuration happen configure?.Invoke(configBuilder); // Construct a configuration binding IoC.Register(made: Made.Of(() => ConfigurationFactory.CreateConfiguration(configBuilder)), reuse: Reuse.Singleton); // Allow custom service injection injection?.Invoke(IoC, Configuration); // Log the startup complete Logger.Information("Perft Framework started in {0}...", Environment.Configuration); }
static async Task Main(string[] args) { ConfigurationFactory.CreateConfiguration(); var serviceProvider = DiStartUp.RegisterServices(); var addressGeoCode = serviceProvider.GetService <IBulkGeoCodeAddressService>(); var sessionGeoCode = serviceProvider.GetService <IBulkGeoCodeSessionService>(); Console.WriteLine("Bulk GeoCode Address: Enter '1'"); Console.WriteLine("Bulk GeoCode Session: Enter '2'"); var input = Console.ReadLine(); if (!int.TryParse(input, out int userChoice)) { Console.WriteLine("Unable to process input value"); } if (userChoice == 1) { await addressGeoCode.GenerateGeoCodingForAddressAsync(); } else if (userChoice == 2) { await sessionGeoCode.GenerateGeoCodingForSessionAsync(); } else { Console.WriteLine("Value not recognised"); } DiStartUp.DisposeServices(); Console.WriteLine("DisposeServices"); }
public ApplicationContext CreateDbContext(string[] args) { var configuration = ConfigurationFactory.CreateConfiguration(); return(new ApplicationContext(configuration)); }