Skip to content

Commit f31e280

Browse files
committed
Add nuspec file
Update static constructor location so it doesn't override things incorrectly
1 parent 824be6c commit f31e280

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

RedditSharp/Reddit.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ public class Reddit
4141

4242
#endregion
4343

44-
#region Static Variables
45-
46-
static Reddit()
47-
{
48-
DefaultWebAgent.UserAgent = "";
49-
DefaultWebAgent.RateLimit = DefaultWebAgent.RateLimitMode.Pace;
50-
DefaultWebAgent.Protocol = "https";
51-
DefaultWebAgent.RootDomain = "www.reddit.com";
52-
}
53-
54-
#endregion
5544

5645
internal IWebAgent WebAgent { get; set; }
5746
/// <summary>

RedditSharp/RedditSharp.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@
105105
<Compile Include="ToolBoxUserNotes.cs" />
106106
<Compile Include="Exceptions\ToolBoxUserNotesException.cs" />
107107
</ItemGroup>
108-
<ItemGroup />
108+
<ItemGroup>
109+
<None Include="RedditSharp.nuspec" />
110+
</ItemGroup>
109111
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110112
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
111113
Other similar extension points exist, see Microsoft.Common.targets.

RedditSharp/RedditSharp.nuspec

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
4+
<id>RedditSharp</id>
5+
<version>1.1.0</version>
6+
<authors>Meepster23</authors>
7+
<owners>RobIII, Meepster23</owners>
8+
<licenseUrl>https://github.com/CrustyJew/RedditSharp/blob/master/LICENSE</licenseUrl>
9+
<projectUrl>https://github.com/CrustyJew/RedditSharp</projectUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>C# Implementation of the Reddit API</description>
12+
<tags>Reddit API</tags>
13+
<iconUrl>http://i.imgur.com/8ONCXMl.png</iconUrl>
14+
<releaseNotes>
15+
Minor bugfixes, tweaks and improvements
16+
</releaseNotes>
17+
<summary>
18+
RedditSharp is a .NET library for working with the Reddit API. It is incomplete. If you want
19+
more features out of it, you are expected to add them yourself and submit a pull request on
20+
GitHub. More details are available in the README.
21+
</summary>
22+
<language>en-US</language>
23+
<dependencies>
24+
<dependency id="Newtonsoft.Json" version="8.0.3" />
25+
<dependency id="HtmlAgilityPack" version="1.4.9" />
26+
</dependencies>
27+
</metadata>
28+
<files>
29+
<file src="\RedditSharp\bin\Release\RedditSharp.dll" target="lib" />
30+
</files>
31+
</package>

RedditSharp/WebAgent.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,32 @@ public enum RateLimitMode
7575
/// <summary>
7676
/// UTC DateTime of last request made to Reddit API
7777
/// </summary>
78-
public DateTime LastRequest
78+
public DateTime LastRequest
7979
{
8080
get { return _lastRequest; }
8181
}
8282
/// <summary>
8383
/// UTC DateTime of when the last burst started
8484
/// </summary>
85-
public DateTime BurstStart
85+
public DateTime BurstStart
8686
{
8787
get { return _burstStart; }
8888
}
8989
/// <summary>
9090
/// Number of requests made during the current burst
9191
/// </summary>
92-
public int RequestsThisBurst
92+
public int RequestsThisBurst
9393
{
9494
get { return _requestsThisBurst; }
9595
}
9696

97+
static WebAgent()
98+
{
99+
UserAgent = "";
100+
RateLimit = RateLimitMode.Pace;
101+
Protocol = "https";
102+
RootDomain = "www.reddit.com";
103+
}
97104

98105
public virtual JToken CreateAndExecuteRequest(string url)
99106
{
@@ -174,7 +181,7 @@ protected virtual void EnforceRateLimit()
174181
switch (RateLimit)
175182
{
176183
case RateLimitMode.Pace:
177-
while ((DateTime.UtcNow - _lastRequest).TotalSeconds < 60.0/limitRequestsPerMinute)// Rate limiting
184+
while ((DateTime.UtcNow - _lastRequest).TotalSeconds < 60.0 / limitRequestsPerMinute)// Rate limiting
178185
Thread.Sleep(250);
179186
_lastRequest = DateTime.UtcNow;
180187
break;

0 commit comments

Comments
 (0)