private void RegisterPublisher(GlimpseCoreServiceCollectionBuilder services) { var configurationBuilder = new ConfigurationBuilder(); var fileProvider = configurationBuilder.GetFileProvider(); if (fileProvider.GetFileInfo("glimpsecore.json").Exists) { var configuration = configurationBuilder.AddJsonFile("glimpsecore.json").Build(); var section = configuration.GetSection("resources"); services.Configure <ResourceOptions>(section); services.Replace(new ServiceDescriptor(typeof(IMessagePublisher), typeof(HttpMessagePublisher), ServiceLifetime.Transient)); } // TODO: If I reach this line, than GlimpseCore has no way to send data from point A to B. Should we blow up? }
public void RegisterServices(GlimpseCoreServiceCollectionBuilder services) { services.AddOptions(); // // Common // services.AddSingleton <IServerBroker, DefaultServerBroker>(); services.AddSingleton <IStorage, InMemoryStorage>(); services.AddSingleton <IResourceManager, ResourceManager>(); // // Options // services.AddTransient <IConfigureOptions <GlimpseCoreServerOptions>, GlimpseCoreServerOptionsSetup>(); services.AddTransient <IExtensionProvider <IAllowClientAccess>, DefaultExtensionProvider <IAllowClientAccess> >(); services.AddTransient <IExtensionProvider <IAllowAgentAccess>, DefaultExtensionProvider <IAllowAgentAccess> >(); services.AddTransient <IExtensionProvider <IResource>, DefaultExtensionProvider <IResource> >(); services.AddTransient <IExtensionProvider <IResourceStartup>, DefaultExtensionProvider <IResourceStartup> >(); services.AddSingleton <IAllowRemoteProvider, DefaultAllowRemoteProvider>(); services.AddSingleton <IMetadataProvider, DefaultMetadataProvider>(); if (!services.Any(s => s.ServiceType == typeof(IMessagePublisher))) { services.AddSingleton <IMessagePublisher, InProcessPublisher>(); } if (services.Any(s => s.ServiceType == typeof(IResourceOptionsProvider))) { services.Replace(new ServiceDescriptor( typeof(IResourceOptionsProvider), typeof(DefaultResourceOptionsProvider), ServiceLifetime.Singleton)); } else { services.AddSingleton <IResourceOptionsProvider, DefaultResourceOptionsProvider>(); } }