public static IServiceCollection AddNotificationServices( this IServiceCollection services, Action <NotificationsOptions> configureOptions) { // register the configured options for DI services.AddOptions <NotificationsOptions>().Configure(o => configureOptions(o)); services.AddScoped <IPushNotifyer, AndroidNotifyer>(); services.AddScoped <INotificationHubClient>(provider => { var factory = provider.GetRequiredService <IHttpMessageHandlerFactory>(); var options = provider.GetRequiredService <IOptions <NotificationsOptions> >(); var hubSettings = new NotificationHubSettings { MessageHandler = factory.CreateHandler() }; return(new NotificationHubClient( options.Value.AzureNotificationHub.ConnectionString, options.Value.AzureNotificationHub.HubName, hubSettings)); }); // docs: https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/servicebus/Azure.Messaging.ServiceBus services.AddSingleton(provider => { var options = provider.GetRequiredService <IOptions <NotificationsOptions> >(); return(new ServiceBusClient(options.Value.Scheduler.AzureServiceBus.ConnectionString)); }); services.AddScoped <INotificationScheduler, ServiceBusNotificationScheduler>(); services.AddHostedService <NotificationDispatcher>(); return(services); }
public AzureNotificationHubConfiguration( string connectionString, string hubName, NotificationHubSettings notificationHubSettings = null) { ConnectionString = Ensure.String.IsNotNullOrWhiteSpace(connectionString, nameof(connectionString)); HubName = Ensure.String.IsNotNullOrWhiteSpace(hubName, nameof(hubName)); NotificationHubSettings = notificationHubSettings ?? new NotificationHubSettings(); }
public static void ConfigureAppSettings(this IServiceCollection services, IConfiguration configuration) { var azureAdGraphConfiguration = new AzureAdGraphSettings() { AzureAdB2CTenant = configuration["AzureAdGraph:AzureAdB2CTenant"], ClientId = configuration["AzureAdGraph:ClientId"], ClientSecret = configuration["AzureAdGraph:ClientSecret"], PolicyName = configuration["AzureAdGraph:PolicyName"], ApiUrl = configuration["AzureAdGraph:ApiUrl"], ApiVersion = configuration["AzureAdGraph:ApiVersion"], ExtensionsAppClientId = configuration["AzureAdGraph:ExtensionsAppClientId"] }; services.AddSingleton(azureAdGraphConfiguration); var azureAdB2CSettings = new AzureAdB2CSettings() { ClientId = configuration["AzureAdB2C:ClientId"], Tenant = configuration["AzureAdB2C:Tenant"], Policy = configuration["AzureAdB2C:Policy"] }; services.AddSingleton(azureAdB2CSettings); var microsoftGraphSettings = new MicrosoftGraphSettings() { AzureAdB2CTenant = configuration["MicrosoftGraph:AzureAdB2CTenant"], ClientId = configuration["MicrosoftGraph:ClientId"], ClientSecret = configuration["MicrosoftGraph:ClientSecret"], ApiUrl = configuration["MicrosoftGraph:ApiUrl"], ApiVersion = configuration["MicrosoftGraph:ApiVersion"] }; services.AddSingleton(microsoftGraphSettings); var cosmosDbSettings = new CosmosDbSettings() { Account = configuration["CosmosDb:Account"], Key = configuration["CosmosDb:Key"], DatabaseName = configuration["CosmosDb:DatabaseName"], TutorLearningProfilesContainerName = configuration["CosmosDb:TutorLearningProfilesContainerName"], ChatMessagesContainerName = configuration["CosmosDb:ChatMessagesContainerName"] }; services.AddSingleton(cosmosDbSettings); var notificationHubSettings = new NotificationHubSettings() { HubName = configuration["NotificationHub:HubName"], HubDefaultFullSharedAccessSignature = configuration["NotificationHub:HubDefaultFullSharedAccessSignature"] }; services.AddSingleton(notificationHubSettings); }
private NamespaceManager CreateNamespaceManager(RecordingMode recordingMode, string connectionString) { if (recordingMode == RecordingMode.Playback) { _notificationHubName = "test"; _namespaceUriString = "https://sample.servicebus.windows.net/"; } var namespaceManagerSettings = new NotificationHubSettings(); namespaceManagerSettings.MessageHandler = _testServer; return(new NamespaceManager(connectionString, namespaceManagerSettings)); }
public NotificationHubFactory(NotificationHubSettings notificationHubSettings) { _notificationHubSettings = notificationHubSettings; NotificationHubClient = NotificationHubClient.CreateClientFromConnectionString(_notificationHubSettings.HubDefaultFullSharedAccessSignature, _notificationHubSettings.HubName); }
public NotificationHubProxy(NotificationHubSettings settings) { _settings = settings; _hubClient = NotificationHubClient.CreateClientFromConnectionString(settings.ConnectionString, settings.HubName); }