private static IServiceProvider CreateServiceContainer(IConfiguration configuration) { var serviceCollection = new ServiceCollection(); serviceCollection.Configure <NotionVisualizerOptions>(o => configuration.GetSection(nameof(NotionVisualizer)).Bind(o)); serviceCollection.Configure <CytoscapeGeneratorOptions>(o => configuration.GetSection(nameof(CytoscapeGenerator)).Bind(o)); serviceCollection.Configure <ExcelGeneratorOptions>(o => configuration.GetSection(nameof(ExcelGenerator)).Bind(o)); serviceCollection.Configure <NotionClientOptions>(o => configuration.GetSection(nameof(NotionClient)).Bind(o)); serviceCollection.Configure <RestClientOptions>(o => configuration.GetSection(nameof(RestClient)).Bind(o)); serviceCollection.AddLogging(loggingBuilder => { loggingBuilder .AddConsole() .AddConfiguration(configuration.GetSection("Logging")); }); serviceCollection.AddTransient <IRestClient, RestClient>(); ServiceConfigurator.Configure(serviceCollection); serviceCollection.AddTransient <INotionClient, NotionClient>(); serviceCollection.AddTransient <IGenerator, CytoscapeGenerator>(); serviceCollection.AddTransient <IGenerator, ExcelGenerator>(); serviceCollection.AddTransient <Visualizer>(); return(serviceCollection.BuildServiceProvider()); }
public SchedulingTests() { var services = new ServiceCollection(); ServiceConfigurator.Configure(services); var serviceProvider = services.BuildServiceProvider(); _schedularService = serviceProvider.GetService <ISchedularService>(); }
public App() { InitializeComponent(); ServiceConfigurator.Configure(); myOApp.DataAccess.DependencyInjection.ServiceConfigurator.Configure(); EventsService = DependencyService.Get <IEventsService>(); DialogService = DependencyService.Get <IDialogService>(); MainPage = new AppShell(); ThemeHelper.ChangeTheme(Settings.Current.Theme); }
public static void Configure(WebApplicationBuilder builder) { var serviceCollection = builder.Services; var configuration = builder.Configuration; serviceCollection.Configure <NotionGraphApiOptions>(o => configuration.GetSection(nameof(NotionGraphApi)).Bind(o)); serviceCollection.Configure <NotionClientOptions>(o => configuration.GetSection(nameof(NotionClient)).Bind(o)); serviceCollection.Configure <RestClientOptions>(o => configuration.GetSection(nameof(RestClient)).Bind(o)); serviceCollection.AddTransient <IRestClient, RestClient>(); ServiceConfigurator.Configure(serviceCollection); serviceCollection.AddTransient <INotionClient, NotionClient>(); serviceCollection.AddSingleton(InitializeDatabase); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc(); services.AddMediatR(); services.AddMediatR(typeof(GenerateSchedule).Assembly, typeof(GenerateSchedule).Assembly ); ServiceConfigurator.Configure(services); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Scheduling API", Version = "v1" }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); }
/// <summary> /// Constructor /// </summary> public MainWindow() { InitializeComponent(); //MessageBox.Show("Starting up the client...", "NuvoControl"); StartupWindow startupWindow = new StartupWindow(); startupWindow.Show(); Thread.Sleep(1000); System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; _log.Trace(m => m("*********** NuvoControl Viewer started *********** (Version={0})", version.ToString())); bool serviceDiscovered = false; try { DiscoverServices(); serviceDiscovered = true; } catch (Exception exc) { StringBuilder message = new StringBuilder("Failed to start up the viewer.\nThe viewer could not discover the service.\n\n"); message.Append("\n\nException message:\n"); message.Append(exc.Message); _log.Fatal(message.ToString()); MessageBox.Show(message.ToString(), "Nuvo Control Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (serviceDiscovered && ServiceProxy.ServiceDiscovery.DiscoveredServers.Count > 0) { _textServerName.Text = ""; // Select server in case more than one service is available ... if (ServiceProxy.ServiceDiscovery.DiscoveredServers.Count > 1) { // Display Server Dialog to select server to connect ServerWindow serverWindow = new ServerWindow(); serverWindow.ShowDialog(); _textServerName.Text = serverWindow._ctrlServerConnect.SelectedServer; } else { _textServerName.Text = ServiceProxy.ServerName; } _textServerName.LostFocus += new RoutedEventHandler(_textServerName_LostFocus); ServiceProxy.ServiceDiscovery.SelectedServer = _textServerName.Text; if (_textServerName.Text.Length > 0) { bool configRead = false; try { ServiceConfigurator.Configure(Properties.Settings.Default.TestMode); // set true in case of 'test' mode ReadConfiguration(); configRead = true; } catch (Exception exc) { StringBuilder message = new StringBuilder("Failed to start up the viewer.\nThe viewer could not retrieve the configuration from the service.\n\n"); message.Append("Shut down the viewer and check following points:"); message.Append("\n- The service is running."); message.Append("\n- The configured service address and port is proper."); message.Append("\n- The configured viewer IP or name is proper."); message.Append("\n\nException message:\n"); message.Append(exc.Message); _log.Fatal(message.ToString()); MessageBox.Show(message.ToString(), "Nuvo Control Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (configRead && serviceDiscovered) { InitializeViews(); InitializeViewModel(); } } } startupWindow.Close(); }