Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af20167

Browse files
committed
General improvements to the repository.
1 parent baec759 commit af20167

File tree

15 files changed

+103
-32
lines changed

15 files changed

+103
-32
lines changed

‎StackExchange.NET/StackExchange.NET/Clients/PostsClient.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#region Using Directives
22

3-
using System;
43
using System.Collections.Generic;
5-
using System.Web;
64
using StackExchange.NET.Helpers;
75
using StackExchange.NET.Interfaces;
86
using StackExchange.NET.Models;

‎StackExchange.NET/StackExchange.NET/Clients/QuestionsClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
using System;
1+
#region Using Directives
2+
3+
using System;
24
using System.Collections.Generic;
35
using StackExchange.NET.Helpers;
46
using StackExchange.NET.Interfaces;
57
using StackExchange.NET.Models;
68

9+
#endregion
10+
711
namespace StackExchange.NET.Clients
812
{
913
public partial class StackExchangeClient : IQuestions

‎StackExchange.NET/StackExchange.NET/Clients/StackExchangeClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ namespace StackExchange.NET.Clients
77
public partial class StackExchangeClient
88
{
99
private readonly string _baseApiUrl;
10-
private readonly HttpClient _httpClient;
10+
private static HttpClient _httpClient;
1111
private readonly string _apiKey;
1212

13+
/// <summary>
14+
/// Provide your apiKey to access the Client
15+
/// </summary>
16+
/// <param name="apiKey"></param>
17+
/// <exception cref="Exception"></exception>
1318
public StackExchangeClient(string apiKey)
1419
{
1520
if (string.IsNullOrWhiteSpace(apiKey))

‎StackExchange.NET/StackExchange.NET/Clients/SuggestedEditClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
using System.Collections.Generic;
1+
#region Using Directives
2+
3+
using System.Collections.Generic;
24
using StackExchange.NET.Helpers;
35
using StackExchange.NET.Interfaces;
46
using StackExchange.NET.Models;
57

8+
#endregion
9+
610
namespace StackExchange.NET.Clients
711
{
812
public partial class StackExchangeClient : ISuggestedEdits

‎StackExchange.NET/StackExchange.NET/Clients/TagsClient.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
using System.Collections.Generic;
1+
#region Using Directives
2+
3+
using System.Collections.Generic;
24
using StackExchange.NET.Helpers;
35
using StackExchange.NET.Interfaces;
46
using StackExchange.NET.Models;
57

8+
#endregion
9+
610
namespace StackExchange.NET.Clients
711
{
812
public partial class StackExchangeClient : ITags
@@ -45,15 +49,15 @@ BaseResponse<Tags> ITags.GetModeratorOnlyTags(TagFilter filter)
4549
return response;
4650
}
4751

48-
BaseResponse<TagSynonyms> ITags.GetAllTagSynonyms(TagFilter filter)
52+
BaseResponse<TagSynonym> ITags.GetAllTagSynonyms(TagFilter filter)
4953
{
5054
var url = ApiUrlBuilder
5155
.Initialize(_apiKey)
5256
.ForClient(ClientType.Tags,"synonyms")
5357
.WithFilter(filter)
5458
.GetApiUrl();
5559

56-
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagSynonyms>>().ValidateApiResponse();
60+
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagSynonym>>().ValidateApiResponse();
5761
return response;
5862
}
5963

@@ -81,7 +85,7 @@ BaseResponse<Tags> ITags.GetRelatedTags(List<string> tags)
8185
return response;
8286
}
8387

84-
BaseResponse<TagSynonyms> ITags.GetSynonymsForTags(List<string> tags, TagFilter filter)
88+
BaseResponse<TagSynonym> ITags.GetSynonymsForTags(List<string> tags, TagFilter filter)
8589
{
8690
var url = ApiUrlBuilder
8791
.Initialize(_apiKey)
@@ -90,7 +94,7 @@ BaseResponse<TagSynonyms> ITags.GetSynonymsForTags(List<string> tags, TagFilter
9094
.WithIds(tags,"synonyms")
9195
.GetApiUrl();
9296

93-
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagSynonyms>>().ValidateApiResponse();
97+
var response = _httpClient.GetAsync(url).Result.ReadAsJsonAsync<Data<TagSynonym>>().ValidateApiResponse();
9498
return response;
9599
}
96100

‎StackExchange.NET/StackExchange.NET/Helpers/ApiUrlBuilder.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
using System.Collections.Generic;
1+
#region Using Directives
2+
3+
using System.Collections.Generic;
24
using System.Web;
5+
using StackExchange.NET.Interfaces;
36
using StackExchange.NET.Models;
47

8+
#endregion
9+
510
namespace StackExchange.NET.Helpers
611
{
712
public class ApiUrlBuilder : IApiUrlHelper

‎StackExchange.NET/StackExchange.NET/Helpers/ExtensionMethods.cs

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
using System;
1+
#region Using Directives
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Net.Http;
57
using System.Web;
68
using Newtonsoft.Json;
79
using StackExchange.NET.Models;
810

11+
#endregion
12+
913
namespace StackExchange.NET.Helpers
1014
{
1115
internal static class ExtensionMethods
@@ -26,22 +30,53 @@ internal static string GetQueryParams(this Filter filters)
2630
{
2731
if (filters == null)
2832
return string.Empty;
29-
var dictionary = new Dictionary<string, dynamic>()
30-
{
31-
{"fromdate",filters.FromDate.ToUnixTime() },
32-
{"todate",filters.ToDate.ToUnixTime() },
33-
{"max",filters.Max.ToUnixTime() },
34-
{"min", filters.Min.ToUnixTime()},
35-
{"order", filters.Order.ToString().ToLower()},
36-
{"Page", filters.Page},
37-
{"PageSize", filters.PageSize},
38-
{"Sort", filters.Sort.ToString().ToLower()},
39-
{"Site", filters.Site.ToLower()},
40-
};
33+
//var dictionary = new Dictionary<string, dynamic>()
34+
//{
35+
// {"fromdate",filters.FromDate.ToUnixTime() },
36+
// {"todate",filters.ToDate.ToUnixTime() },
37+
// {"max",filters.Max.ToUnixTime() },
38+
// {"min", filters.Min.ToUnixTime()},
39+
// {"order", filters.Order.ToString().ToLower()},
40+
// {"Page", filters.Page},
41+
// {"PageSize", filters.PageSize},
42+
// {"Sort", filters.Sort.ToString().ToLower()},
43+
// {"Site", filters.Site.ToLower()},
44+
//};
4145

46+
var dictionary = filters.AddValidKeys();
4247
return dictionary.ToQueryString();
4348
}
4449

50+
internal static Dictionary<string, dynamic> AddValidKeys(this Filter filter)
51+
{
52+
var result = new Dictionary<string, dynamic>();
53+
54+
#region IsThereABetterWayofDoingThis
55+
56+
if (filter.FromDate != null)
57+
result.Add("fromdata", filter.FromDate.ToUnixTime());
58+
if (filter.ToDate != null)
59+
result.Add("todate", filter.ToDate.ToUnixTime());
60+
if (filter.Max != null)
61+
result.Add("max", filter.Max.ToUnixTime());
62+
if (filter.Min != null)
63+
result.Add("min", filter.Min.ToUnixTime());
64+
if (filter.Order != null)
65+
result.Add("order", filter.Order.ToString().ToLower());
66+
if (filter.Page != null)
67+
result.Add("page", filter.Page);
68+
if (filter.PageSize != null)
69+
result.Add("pageSize", filter.PageSize);
70+
if (filter.Sort != null)
71+
result.Add("sort", filter.Sort.ToString().ToLower());
72+
if (filter.Site != null)
73+
result.Add("site", filter.Site.ToLower());
74+
75+
#endregion
76+
77+
return result;
78+
}
79+
4580
internal static BaseResponse<T> ValidateApiResponse<T>(this Data<T> data)
4681
{
4782
var result = new BaseResponse<T>();
@@ -72,6 +107,5 @@ internal static T ReadAsJsonAsync<T>(this HttpResponseMessage content)
72107
{
73108
return JsonConvert.DeserializeObject<T>(content.Content.ReadAsStringAsync().Result);
74109
}
75-
76110
}
77111
}

‎StackExchange.NET/StackExchange.NET/Helpers/MakeSure.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
using System;
1+
#region Using Directives
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46

7+
#endregion
8+
59
namespace StackExchange.NET.Helpers
610
{
711
/// <summary>

‎StackExchange.NET/StackExchange.NET/Helpers/IApiUrlHelper.cs renamed to ‎StackExchange.NET/StackExchange.NET/Interfaces/IApiUrlHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System.Collections.Generic;
2+
using StackExchange.NET.Helpers;
23
using StackExchange.NET.Models;
34

4-
namespace StackExchange.NET.Helpers
5+
namespace StackExchange.NET.Interfaces
56
{
67
public interface IApiUrlHelper
78
{

‎StackExchange.NET/StackExchange.NET/Interfaces/ITags.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface ITags
3232
/// </summary>
3333
/// <param name="filter"></param>
3434
/// <returns></returns>
35-
BaseResponse<TagSynonyms> GetAllTagSynonyms(TagFilter filter);
35+
BaseResponse<TagSynonym> GetAllTagSynonyms(TagFilter filter);
3636
/// <summary>
3737
/// Get frequently asked questions in a set of tags.
3838
/// </summary>
@@ -51,7 +51,7 @@ public interface ITags
5151
/// <param name="tags"></param>
5252
/// <param name="filter"></param>
5353
/// <returns></returns>
54-
BaseResponse<TagSynonyms> GetSynonymsForTags(List<string> tags, TagFilter filter);
54+
BaseResponse<TagSynonym> GetSynonymsForTags(List<string> tags, TagFilter filter);
5555
/// <summary>
5656
/// Get the top answer posters in a specific tag, either in the last month or for all time.
5757
/// Enter any tag for param1 and period can be all_time or month

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /