コード例 #1
0
        public MapDataDownloadService(IApplicationReleaseConfiguration configuration, IHttpClientFactory httpClientFactory)
        {
            var server = configuration.GetString("MAPDATA_SERVER");

            hasMapServer      = server != null;
            this.mapServerUrl = new Uri(server ?? "http://localhost");
            this.client       = httpClientFactory.Factory();
        }
コード例 #2
0
    public async Task <CommentResult> Publish(string username, string text)
    {
        var http = httpClientFactory.Factory();

        var json = JsonConvert.SerializeObject(new Request()
        {
            Username = username, Text = text
        });
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        try
        {
            var result = await http.PostAsync($"{updateServer}/Comments/Add", content);

            if (result.StatusCode == HttpStatusCode.Unauthorized)
            {
                return(CommentResult.TooManyComments);
            }

            if (result.StatusCode == HttpStatusCode.Forbidden)
            {
                return(CommentResult.InvalidIpAddress);
            }

            if (result.StatusCode == HttpStatusCode.OK)
            {
                return(CommentResult.Success);
            }

            return(CommentResult.ServerProblem);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            return(CommentResult.InternetProblem);
        }
    }
コード例 #3
0
        public IUpdateClient Create(Uri updateServerUrl, string marketplace, string?key, Platforms platform)
        {
            var httpClient = httpClientFactory.Factory();

            return(new UpdateClient(updateServerUrl, marketplace, key, platform, httpClient));
        }