Beispiel #1
0
        public async Task <IServiceProvider> ConfigureServices()
        {
            Imgur ImgurConnect = new Imgur(WebConnect);
            await ImgurConnect.LoadConfig(new FileData("Config/ImgurConfig.json"));

            await ImgurConnect.SetupConnection();

            WeatherUnderground WeatherUndergroundConnect = new WeatherUnderground(WebConnect);
            await WeatherUndergroundConnect.LoadConfig(new FileData("Config/WeatherUndergroundConfig.json"));

            Cleverbot CleverbotConnect = new Cleverbot(WebConnect);
            await CleverbotConnect.LoadConfig(new FileData("Config/CleverbotConfig.json"));


            var sc = new ServiceCollection();

            sc.AddSingleton(Client);
            sc.AddSingleton(Console);
            sc.AddSingleton(ImgurConnect);
            sc.AddSingleton(WeatherUndergroundConnect);
            sc.AddSingleton(CleverbotConnect);
            sc.AddSingleton <CommandHandler>();
            sc.AddSingleton(new CommandService(new CommandServiceConfig {
                CaseSensitiveCommands = false, ThrowOnError = true
            }));
            sc.AddSingleton(new TestService("testing: ", Console));
            sc.AddSingleton <WeatherUndergroundService>();
            sc.AddSingleton <ImgurService>();
            sc.AddSingleton <CleverbotService>();
            sc.AddSingleton <ScheduleMaker>();
            sc.AddSingleton <TvModeService>();

            var sp = sc.BuildServiceProvider();

            sp.GetService <TestService>();
            sp.GetService <ImgurService>();
            sp.GetService <CleverbotService>();
            sp.GetService <TvModeService>();
            sp.GetService <WeatherUndergroundService>();
            return(sp);
        }