Esempio n. 1
0
        public IServiceProvider Initialize()
        {
            IServiceProvider minecraftUtils = new ServiceCollection()
                                              .AddSingletonMinecraftClient()
                                              .AddSingletonTaskExecutor()
                                              .BuildServiceProvider();

            IMinecraftClient minecraftClient = minecraftUtils.GetService <IMinecraftClient>();

            IBotStore              botStore         = new BotStore();
            IGuildsMonitor         guildsMonitor    = new GuildsMonitor(botStore);
            IGuildCollection       guildsCollection = guildsMonitor.Load();
            IMinecraftPlayerClient mojangClient     = new MinecraftPlayerClient();
            IConfig config = new ConfigStore();

            IServiceProvider serviceProvider = new ServiceCollection()
                                               .AddSingleton(botStore)
                                               .AddSingleton(guildsCollection)
                                               .AddSingleton(guildsMonitor)
                                               .AddSingleton(mojangClient)
                                               .AddSingleton(minecraftClient)
                                               .AddSingleton(config)
                                               .BuildServiceProvider();

            return(serviceProvider);
        }
Esempio n. 2
0
        public static string UploadData(string key, string value)
        {
            var botStoreModel = new BotStore();

            botStoreModel.BotStoreName  = key;
            botStoreModel.BotStoreValue = value;
            botStoreModel.LastUpdatedBy = _appSettings.ServerSettings.HTTPGuid;
            botStoreModel.LastUpdatedOn = DateTime.Now;

            var scriptJson = JsonConvert.SerializeObject(botStoreModel);

            _httpLogger.Information("Posting Json to Upload API: " + scriptJson);

            //create webclient and upload
            WebClient webClient = new WebClient();

            webClient.Headers["Content-Type"] = "application/json";
            var api = new Uri(_appSettings.ServerSettings.HTTPServerURL + "/api/BotStore/Add");

            return(webClient.UploadString(api, "POST", scriptJson));
        }