Example #1
0
        public static IServiceCollection AddSlackNet(this IServiceCollection serviceCollection, Action <SlackServiceConfiguration> configure)
        {
            serviceCollection.AddSingleton <IEventsObservables, EventsObservables>();

            var configuration = new SlackServiceConfiguration(serviceCollection);

            configuration.RegisterEventHandler <IEventsObservables>();
            configure(configuration);
            Default.RegisterServices((serviceType, createService) => serviceCollection.AddTransient(serviceType, c => createService(c.GetService)));

            serviceCollection.TryAddSingleton <ISlackRequestHandler, SlackRequestHandler>();
            serviceCollection.TryAddSingleton <IEventHandler, CompositeEventHandler>();
            serviceCollection.TryAddSingleton <IAsyncBlockActionHandler, CompositeBlockActionHandler>();
            serviceCollection.TryAddSingleton <IBlockOptionProvider, SwitchingBlockOptionProvider>();
            serviceCollection.TryAddSingleton <IAsyncMessageShortcutHandler, CompositeMessageShortcutHandler>();
            serviceCollection.TryAddSingleton <IAsyncGlobalShortcutHandler, CompositeGlobalShortcutHandler>();
            serviceCollection.TryAddSingleton <IOptionProvider, SwitchingOptionProvider>();
            serviceCollection.TryAddSingleton <IAsyncViewSubmissionHandler, SwitchingViewSubmissionHandler>();
            serviceCollection.TryAddSingleton <IAsyncSlashCommandHandler, SwitchingSlashCommandHandler>();
            serviceCollection.TryAddSingleton <IInteractiveMessageHandler, SwitchingInteractiveMessageHandler>();
            serviceCollection.TryAddSingleton <IDialogSubmissionHandler, SwitchingDialogSubmissionHandler>();
            serviceCollection.AddTransient <ISlackApiClient>(c => new SlackApiClient(c.GetService <IHttp>(), c.GetService <ISlackUrlBuilder>(), c.GetService <SlackJsonSettings>(), configuration.ApiToken));

            return(serviceCollection);
        }
        public static IServiceCollection AddSlackNet(this IServiceCollection serviceCollection, Action <SlackServiceConfiguration> configure)
        {
            var configuration = new SlackServiceConfiguration(serviceCollection);

            configure(configuration);
            Default.RegisterServices((serviceType, createService) => serviceCollection.AddTransient(serviceType, c => createService(c.GetService)));
            serviceCollection.AddSingleton <ISlackEvents, SlackEventsService>();
            serviceCollection.AddSingleton <ISlackActions, SlackActionsService>();
            serviceCollection.AddSingleton <ISlackOptions, SlackOptionsService>();
            serviceCollection.TryAddSingleton <IDialogSubmissionHandler, NullDialogSubmissionHandler>();
            serviceCollection.AddTransient <ISlackApiClient>(c => new SlackApiClient(c.GetService <IHttp>(), c.GetService <ISlackUrlBuilder>(), c.GetService <SlackJsonSettings>(), configuration.ApiToken));

            return(serviceCollection);
        }