├── .gitignore
├── LICENSE
├── Local.testsettings
├── README.md
├── StacMan.Tests
├── ApiVersion21Tests.cs
├── BackoffTests.cs
├── InfoMethodTests.cs
├── IntegrationTests.cs
├── QuestionMethodTests.cs
├── SiteMethodTests.cs
├── StacMan.Tests.csproj
├── StacManResponseTests.cs
├── TagMethodTests.cs
├── UserMethodTests.cs
├── Utilities
│ ├── Assert2.cs
│ └── ExtensionMethods.cs
├── ValidationTests.cs
└── WrapperTests.cs
├── StacMan.sln
├── StacMan.vsmdi
├── StacMan
├── Answers
│ └── Sort.cs
├── ApiUrlBuilder.cs
├── Badges
│ ├── AllSort.cs
│ ├── BadgeType.cs
│ ├── Rank.cs
│ ├── Sort.cs
│ └── UserSort.cs
├── Codegen
│ ├── AccessToken.cs
│ ├── AccountMerge.cs
│ ├── Answer.cs
│ ├── Badge.cs
│ ├── BadgeCount.cs
│ ├── Comment.cs
│ ├── Error.cs
│ ├── Event.cs
│ ├── Filter.cs
│ ├── InboxItem.cs
│ ├── Info.cs
│ ├── Manager.ttinclude
│ ├── Methods.ignore
│ ├── Methods.json
│ ├── Methods.tt
│ ├── MigrationInfo.cs
│ ├── NetworkUser.cs
│ ├── Notice.cs
│ ├── Notification.cs
│ ├── Post.cs
│ ├── Privilege.cs
│ ├── Question.cs
│ ├── QuestionTimeline.cs
│ ├── RelatedSite.cs
│ ├── Reputation.cs
│ ├── ReputationHistory.cs
│ ├── Revision.cs
│ ├── ShallowUser.cs
│ ├── Site.cs
│ ├── StacManClient.AccessTokenMethods.cs
│ ├── StacManClient.AnswerMethods.cs
│ ├── StacManClient.ApplicationMethods.cs
│ ├── StacManClient.BadgeMethods.cs
│ ├── StacManClient.CommentMethods.cs
│ ├── StacManClient.ErrorMethods.cs
│ ├── StacManClient.EventMethods.cs
│ ├── StacManClient.FilterMethods.cs
│ ├── StacManClient.InboxMethods.cs
│ ├── StacManClient.InfoMethods.cs
│ ├── StacManClient.NotificationMethods.cs
│ ├── StacManClient.PostMethods.cs
│ ├── StacManClient.PrivilegeMethods.cs
│ ├── StacManClient.QuestionMethods.cs
│ ├── StacManClient.RevisionMethods.cs
│ ├── StacManClient.SearchMethods.cs
│ ├── StacManClient.SiteMethods.cs
│ ├── StacManClient.SuggestedEditMethods.cs
│ ├── StacManClient.TagMethods.cs
│ ├── StacManClient.UserMethods.cs
│ ├── Styling.cs
│ ├── SuggestedEdit.cs
│ ├── Tag.cs
│ ├── TagScore.cs
│ ├── TagSynonym.cs
│ ├── TagWiki.cs
│ ├── TopTag.cs
│ ├── Types.ignore
│ ├── Types.json
│ ├── Types.tt
│ ├── User.cs
│ ├── UserTimeline.cs
│ ├── Wrapper.cs
│ └── WritePermission.cs
├── Comments
│ └── Sort.cs
├── DateTimeExtensions.cs
├── Events
│ └── EventType.cs
├── Exceptions
│ └── StackExchangeApiException.cs
├── FieldAttribute.cs
├── Filters.BuiltIn.cs
├── InboxItems
│ └── ItemType.cs
├── Notifications
│ └── NotificationType.cs
├── Order.cs
├── Posts
│ ├── PostType.cs
│ └── Sort.cs
├── Properties
│ └── AssemblyInfo.cs
├── QuestionTimelines
│ └── TimelineType.cs
├── Questions
│ ├── AllSort.cs
│ ├── FavoriteSort.cs
│ ├── RelatedSort.cs
│ ├── SearchSort.cs
│ └── Sort.cs
├── ReflectionCache.cs
├── ReputationHistories
│ └── ReputationHistoryType.cs
├── Reputations
│ └── VoteType.cs
├── Revisions
│ └── RevisionType.cs
├── Sites
│ └── SiteState.cs
├── SortAttribute.cs
├── StacMan.csproj
├── StacManClient.ApiRequest.cs
├── StacManClient.Validation.cs
├── StacManClient.cs
├── StacManResponse.cs
├── StacManType.cs
├── Stackie.t4properties
├── SuggestedEdits
│ └── Sort.cs
├── TagSynonyms
│ └── Sort.cs
├── Tags
│ ├── Period.cs
│ └── Sort.cs
├── UserTimelines
│ └── TimelineType.cs
├── Users
│ ├── Sort.cs
│ └── UserType.cs
└── filters
│ └── FilterType.cs
├── TraceAndTestImpact.testsettings
└── packages
└── Moq.4.0.10827
├── License.txt
├── Moq.4.0.10827.nupkg
├── Moq.chm
└── lib
├── NET35
├── Moq.dll
├── Moq.pdb
└── Moq.xml
├── NET40
├── Moq.dll
├── Moq.pdb
└── Moq.xml
└── Silverlight4
├── Castle.Core.dll
├── Moq.Silverlight.dll
├── Moq.Silverlight.pdb
└── Moq.Silverlight.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | *.suo
4 | TestResults/
5 | *.nupkg
6 | _ReSharper.*
7 | *.csproj.user
8 | *.sln.ide
9 | NuGet.CommandLine.*
10 | /.vs
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | =========================================
2 | StacMan is licensed under the MIT License
3 | =========================================
4 |
5 | Copyright (C) 2012 Emmett Nicholas
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Local.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | These are default test settings for a local test run.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Features
2 |
3 | * Supports [**all** Stack Exchange API V2 methods](http://api.stackexchange.com/docs) through version 2.1
4 | * **Easy to use**: one-to-one mapping between StacMan and API methods/params
5 | * **Async is easy**: methods return [`Task`](http://msdn.microsoft.com/en-us/library/dd321424.aspx) so they're [ready for C# 5's `await`](http://msdn.microsoft.com/en-us/vstudio/hh533273)
6 | * Adheres to the [API's throttling rules](http://api.stackexchange.com/docs/throttle)
7 |
8 | ## Get StacMan
9 |
10 | [StacMan is available on NuGet](https://nuget.org/packages/StacMan):
11 |
12 | PM> Install-Package StacMan
13 |
14 | ## Example Usage
15 |
16 | using StackExchange.StacMan;
17 | ...
18 | var client = new StacManClient(key: "my-app-key", version: "2.1");
19 |
20 | **Synchronous**
21 |
22 | var response = client.Questions.GetAll("stackoverflow",
23 | page: 1,
24 | pagesize: 10,
25 | sort: Questions.AllSort.Creation,
26 | order: Order.Desc,
27 | filter: "!mDO35lQRaz").Result;
28 |
29 | foreach (var question in response.Data.Items)
30 | {
31 | Console.WriteLine(question.Title);
32 | }
33 |
34 | **Asynchronous**
35 |
36 | var task = client.Questions.GetAll("stackoverflow",
37 | page: 1,
38 | pagesize: 10,
39 | sort: Questions.AllSort.Creation,
40 | order: Order.Desc,
41 | filter: "!mDO35lQRaz");
42 |
43 | task.ContinueWith(t =>
44 | {
45 | foreach (var question in t.Result.Data.Items)
46 | {
47 | Console.WriteLine(question.Title);
48 | }
49 | });
50 |
51 | **Asynchronous (C# 5)**
52 |
53 | var response = await client.Questions.GetAll("stackoverflow",
54 | page: 1,
55 | pagesize: 10,
56 | sort: Questions.AllSort.Creation,
57 | order: Order.Desc,
58 | filter: "!mDO35lQRaz");
59 |
60 | foreach (var question in response.Data.Items)
61 | {
62 | Console.WriteLine(question.Title);
63 | }
64 |
65 | ## Filters
66 |
67 | StacMan supports the Stack Exhchange API's concept of [filters](http://api.stackexchange.com/docs/filters), which allow applications to specify which fields are included/excluded in the API response.
68 |
69 | When a field is excluded, the property returned by StacMan corresponding to the excluded field assumes the *default value* of the type. For example, when the "default" filter is used, the `AnswerCount` property of the User object returned by StacMan will be 0, since `user.answer_count` is not included by the "default" filter.
--------------------------------------------------------------------------------
/StacMan.Tests/BackoffTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class BackoffTests
14 | {
15 | [TestMethod]
16 | public async Task Backoff_test()
17 | {
18 | var mockSlow = new Mock(null, null);
19 | var mockFast = new Mock(null, null);
20 |
21 | //http://api.stackexchange.com/2.0/users?pagesize=1&site=stackoverflow
22 | mockSlow.FakeGET(response: @"{""backoff"":1,""items"":[{""user_id"":22656,""user_type"":""registered"",""creation_date"":1222430705,""display_name"":""Jon Skeet"",""profile_image"":""http://www.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?d=identicon&r=PG"",""reputation"":431980,""reputation_change_day"":365,""reputation_change_week"":2286,""reputation_change_month"":9666,""reputation_change_quarter"":9666,""reputation_change_year"":44922,""age"":35,""last_access_date"":1335550327,""last_modified_date"":1335533187,""is_employee"":false,""link"":""http://stackoverflow.com/users/22656/jon-skeet"",""website_url"":""http://csharpindepth.com"",""location"":""Reading, United Kingdom"",""account_id"":11683,""badge_counts"":{""gold"":124,""silver"":1896,""bronze"":3221},""accept_rate"":95}],""quota_remaining"":109,""quota_max"":300,""has_more"":true}");
23 | mockFast.FakeGET(response: @"{""items"":[{""user_id"":22656,""user_type"":""registered"",""creation_date"":1222430705,""display_name"":""Jon Skeet"",""profile_image"":""http://www.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?d=identicon&r=PG"",""reputation"":431980,""reputation_change_day"":365,""reputation_change_week"":2286,""reputation_change_month"":9666,""reputation_change_quarter"":9666,""reputation_change_year"":44922,""age"":35,""last_access_date"":1335550327,""last_modified_date"":1335533187,""is_employee"":false,""link"":""http://stackoverflow.com/users/22656/jon-skeet"",""website_url"":""http://csharpindepth.com"",""location"":""Reading, United Kingdom"",""account_id"":11683,""badge_counts"":{""gold"":124,""silver"":1896,""bronze"":3221},""accept_rate"":95}],""quota_remaining"":109,""quota_max"":300,""has_more"":true}");
24 |
25 | var clientSlow = mockSlow.Object;
26 | var clientFast = mockFast.Object;
27 |
28 | await Measure(clientSlow, elapsedMs => Assert.IsTrue(elapsedMs >= 1000));
29 | await Measure(clientFast, elapsedMs => Assert.IsTrue(elapsedMs < 1000));
30 |
31 | clientSlow.RespectBackoffs = false;
32 | await Measure(clientSlow, elapsedMs => Assert.IsTrue(elapsedMs < 1000));
33 |
34 | async Task Measure(StacManClient client, Action verifyElapsedMs)
35 | {
36 | var stopwatch = System.Diagnostics.Stopwatch.StartNew();
37 | var result = await client.Users.GetAll("stackoverflow", pagesize: 1);
38 | var result2 = await client.Users.GetAll("stackoverflow", pagesize: 1);
39 | verifyElapsedMs(stopwatch.ElapsedMilliseconds);
40 | }
41 | }
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/StacMan.Tests/InfoMethodTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class InfoMethodTests
14 | {
15 | [TestMethod]
16 | public async Task Info_get_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/info?site=english
21 | mock.FakeGET(response: @"{""items"":[{""total_questions"":14647,""total_unanswered"":15,""total_accepted"":10674,""total_answers"":41975,""questions_per_minute"":0.01,""answers_per_minute"":0.02,""total_comments"":112674,""total_votes"":251459,""total_badges"":41800,""badges_per_minute"":0.02,""total_users"":17118,""new_active_users"":1,""api_revision"":""2012.4.12.2100""}],""quota_remaining"":291,""quota_max"":300,""has_more"":false}");
22 |
23 | var client = mock.Object;
24 |
25 | var result = await client.Info.Get("english");
26 | Assert.IsTrue(result.Success);
27 |
28 | var info = result.Data.Items.Single();
29 | Assert.AreEqual(14647, info.TotalQuestions);
30 | Assert.AreEqual(15, info.TotalUnanswered);
31 | Assert.AreEqual(10674, info.TotalAccepted);
32 | Assert.AreEqual(41975, info.TotalAnswers);
33 | Assert.AreEqual(.01m, info.QuestionsPerMinute);
34 | Assert.AreEqual(.02m, info.AnswersPerMinute);
35 | Assert.AreEqual(112674, info.TotalComments);
36 | Assert.AreEqual(251459, info.TotalVotes);
37 | Assert.AreEqual(41800, info.TotalBadges);
38 | Assert.AreEqual(.02m, info.BadgesPerMinute);
39 | Assert.AreEqual(17118, info.TotalUsers);
40 | Assert.AreEqual(1, info.NewActiveUsers);
41 | Assert.AreEqual("2012.4.12.2100", info.ApiRevision);
42 | Assert.IsNull(info.Site);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/StacMan.Tests/IntegrationTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace StackExchange.StacMan.Tests
7 | {
8 | [TestClass] // these actually talk over the network
9 | public class IntegrationTests
10 | {
11 | [TestMethod]
12 | public async Task BasicTestNoManager()
13 | {
14 | var client = new StacManClient();
15 |
16 | var sites = await client.Sites.GetAll(pagesize: 50);
17 | Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", sites.ApiUrl);
18 | Assert.AreEqual(50, sites.Data.Items.Count());
19 | Assert.IsTrue(sites.Data.HasMore);
20 | }
21 | [TestMethod]
22 | public async Task BasicTestWithManager()
23 | {
24 | var client = new StacManClient();
25 | client.UserAgent = GetType().Name;
26 | List urls = new List();
27 | client.SetUrlManager(x =>
28 | {
29 | lock (urls) urls.Add(x);
30 | System.Console.WriteLine("Querying: " + x);
31 | return x;
32 | });
33 |
34 | var sites = await client.Sites.GetAll(pagesize: 50);
35 | Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", sites.ApiUrl);
36 | Assert.AreEqual(50, sites.Data.Items.Count());
37 | Assert.IsTrue(sites.Data.HasMore);
38 |
39 | lock (urls)
40 | {
41 | Assert.AreEqual(1, urls.Count);
42 | Assert.AreEqual("http://api.stackexchange.com/2.0/sites?pagesize=50", urls[0]);
43 | }
44 | }
45 |
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan.Tests/QuestionMethodTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class QuestionMethodTests
14 | {
15 | [TestMethod]
16 | public async Task Questions_get_all_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/questions?pagesize=1&fromdate=1328054400&order=desc&sort=activity&tagged=starcraft-2&site=gaming
21 | mock.FakeGET(response: @"{""items"":[{""question_id"":62531,""last_edit_date"":1334545016,""creation_date"":1334446664,""last_activity_date"":1334566818,""score"":1,""answer_count"":2,""title"":""Why does the 'favored' rating change from start of game to end of game in Starcraft 2?"",""tags"":[""starcraft-2"",""multiplayer""],""view_count"":96,""owner"":{""user_id"":2030,""display_name"":""Kelsey"",""reputation"":273,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/395b66642a372ee82bbc821bdc2697a4?d=identicon&r=PG"",""link"":""http://gaming.stackexchange.com/users/2030/kelsey""},""link"":""http://gaming.stackexchange.com/questions/62531/why-does-the-favored-rating-change-from-start-of-game-to-end-of-game-in-starcr"",""is_answered"":true}],""quota_remaining"":-81147,""quota_max"":300,""has_more"":true}");
22 |
23 | var client = mock.Object;
24 |
25 | var result = await client.Questions.GetAll("gaming", pagesize: 1, fromdate: new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc), order: Order.Desc, sort: Questions.AllSort.Activity, tagged: "starcraft-2");
26 | Assert.IsTrue(result.Success);
27 |
28 | var question = result.Data.Items.Single();
29 | Assert.AreEqual(1334545016L.ToDateTime(), question.LastEditDate);
30 | Assert.AreEqual(1334446664L.ToDateTime(), question.CreationDate);
31 | Assert.AreEqual(1334566818L.ToDateTime(), question.LastActivityDate);
32 | Assert.AreEqual(1, question.Score);
33 | Assert.AreEqual(2, question.AnswerCount);
34 | Assert.AreEqual("Why does the 'favored' rating change from start of game to end of game in Starcraft 2?", question.Title);
35 | Assert.AreEqual(2, question.Tags.Length);
36 | Assert.AreEqual("starcraft-2", question.Tags.First());
37 | Assert.AreEqual(96, question.ViewCount);
38 | Assert.AreEqual(2030, question.Owner.UserId);
39 | Assert.AreEqual("Kelsey", question.Owner.DisplayName);
40 | Assert.AreEqual(273, question.Owner.Reputation);
41 | Assert.AreEqual(Users.UserType.Registered, question.Owner.UserType);
42 | Assert.AreEqual("http://www.gravatar.com/avatar/395b66642a372ee82bbc821bdc2697a4?d=identicon&r=PG", question.Owner.ProfileImage);
43 | Assert.AreEqual("http://gaming.stackexchange.com/users/2030/kelsey", question.Owner.Link);
44 | Assert.AreEqual("http://gaming.stackexchange.com/questions/62531/why-does-the-favored-rating-change-from-start-of-game-to-end-of-game-in-starcr", question.Link);
45 | Assert.IsTrue(question.IsAnswered);
46 | }
47 |
48 | [TestMethod]
49 | public async Task Questions_by_id_test()
50 | {
51 | var mock = new Mock(null, null);
52 |
53 | //http://api.stackexchange.com/2.0/questions/13332?order=desc&sort=activity&site=gaming
54 | mock.FakeGET(response: @"{""items"":[{""question_id"":13332,""last_edit_date"":1296990699,""creation_date"":1278527266,""last_activity_date"":1296990699,""score"":1,""answer_count"":1,""migrated_from"":{""question_id"":161024,""other_site"":{""site_type"":""main_site"",""name"":""Super User"",""logo_url"":""http://cdn.sstatic.net/superuser/img/logo.png"",""api_site_parameter"":""superuser"",""site_url"":""http://superuser.com"",""audience"":""computer enthusiasts and power users"",""icon_url"":""http://cdn.sstatic.net/superuser/img/apple-touch-icon.png"",""site_state"":""normal"",""styling"":{""link_color"":""#1086A4"",""tag_foreground_color"":""#1087A4"",""tag_background_color"":""#FFFFFF""},""launch_date"":1250553600,""favicon_url"":""http://cdn.sstatic.net/superuser/img/favicon.ico"",""related_sites"":[{""name"":""Meta Super User"",""site_url"":""http://meta.superuser.com"",""relation"":""meta"",""api_site_parameter"":""meta.superuser""},{""name"":""Chat Stack Exchange"",""site_url"":""http://chat.stackexchange.com"",""relation"":""chat""}],""twitter_account"":""StackSuper_User""},""on_date"":1293296833},""title"":""How do I run Worms: World Party on Ubuntu?"",""tags"":[""linux"",""unix"",""ubuntu""],""view_count"":845,""owner"":{""display_name"":""gcc"",""user_type"":""does_not_exist""},""link"":""http://gaming.stackexchange.com/questions/13332/how-do-i-run-worms-world-party-on-ubuntu"",""is_answered"":true}],""quota_remaining"":-89970,""quota_max"":300,""has_more"":false}");
55 |
56 | var client = mock.Object;
57 |
58 | var result = await client.Questions.GetByIds("gaming", new int[] { 13332 }, order: Order.Desc, sort: Questions.Sort.Activity);
59 | Assert.IsTrue(result.Success);
60 |
61 | var question = result.Data.Items.Single();
62 | Assert.AreEqual(13332, question.QuestionId);
63 | Assert.IsNull(question.AcceptedAnswerId);
64 | Assert.AreEqual(161024, question.MigratedFrom.QuestionId);
65 | Assert.AreEqual("Super User", question.MigratedFrom.OtherSite.Name);
66 | Assert.AreEqual("#1086A4", question.MigratedFrom.OtherSite.Styling.LinkColor);
67 | Assert.AreEqual(2, question.MigratedFrom.OtherSite.RelatedSites.Length);
68 | Assert.AreEqual(question.Tags.Length, 3);
69 | Assert.AreEqual("gcc", question.Owner.DisplayName);
70 | Assert.AreEqual(Users.UserType.DoesNotExist, question.Owner.UserType);
71 | Assert.IsNull(question.Owner.UserId);
72 | Assert.IsNull(question.Owner.Reputation);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/StacMan.Tests/SiteMethodTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class SiteMethodTests
14 | {
15 | [TestMethod]
16 | public async Task Sites_get_all_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/sites?page=1&pagesize=1
21 | mock.FakeGET(response: @"{""items"":[{""site_type"":""main_site"",""name"":""Stack Overflow"",""logo_url"":""http://cdn.sstatic.net/stackoverflow/img/logo.png"",""api_site_parameter"":""stackoverflow"",""site_url"":""http://stackoverflow.com"",""audience"":""professional and enthusiast programmers"",""icon_url"":""http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png"",""aliases"":[""http://www.stackoverflow.com""],""site_state"":""normal"",""styling"":{""link_color"":""#0077CC"",""tag_foreground_color"":""#3E6D8E"",""tag_background_color"":""#E0EAF1""},""launch_date"":1221436800,""favicon_url"":""http://cdn.sstatic.net/stackoverflow/img/favicon.ico"",""related_sites"":[{""name"":""Stack Overflow Chat"",""site_url"":""http://chat.stackoverflow.com"",""relation"":""chat""}],""markdown_extensions"":[""Prettify""]}],""quota_remaining"":-50833,""quota_max"":300,""has_more"":true}");
22 |
23 | var client = mock.Object;
24 |
25 | var result = await client.Sites.GetAll(filter: "default", page: 1, pagesize: 1);
26 | Assert.IsTrue(result.Success);
27 |
28 | var site = result.Data.Items.Single();
29 |
30 | Assert.AreEqual("main_site", site.SiteType);
31 | Assert.AreEqual("Stack Overflow", site.Name);
32 | Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/logo.png", site.LogoUrl);
33 | Assert.AreEqual("stackoverflow", site.ApiSiteParameter);
34 | Assert.AreEqual("http://stackoverflow.com", site.SiteUrl);
35 | Assert.AreEqual("professional and enthusiast programmers", site.Audience);
36 | Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png", site.IconUrl);
37 | Assert.AreEqual("http://www.stackoverflow.com", site.Aliases.Single());
38 | Assert.AreEqual(StacMan.Sites.SiteState.Normal, site.SiteState);
39 | Assert.AreEqual("#0077CC", site.Styling.LinkColor);
40 | Assert.AreEqual("#3E6D8E", site.Styling.TagForegroundColor);
41 | Assert.AreEqual("#E0EAF1", site.Styling.TagBackgroundColor);
42 | Assert.AreEqual(1221436800L.ToDateTime(), site.LaunchDate);
43 | Assert.AreEqual("http://cdn.sstatic.net/stackoverflow/img/favicon.ico", site.FaviconUrl);
44 | Assert.AreEqual("Stack Overflow Chat", site.RelatedSites.Single().Name);
45 | Assert.AreEqual("http://chat.stackoverflow.com", site.RelatedSites.Single().SiteUrl);
46 | Assert.AreEqual("chat", site.RelatedSites.Single().Relation);
47 | Assert.AreEqual("Prettify", site.MarkdownExtensions.Single());
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/StacMan.Tests/StacMan.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/StacMan.Tests/StacManResponseTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class StacManResponseTests
14 | {
15 | [TestMethod]
16 | public async Task Api_web_exception_response()
17 | {
18 | var mock = new Mock(null, null);
19 | var client = mock.Object;
20 |
21 | mock.FakeGET(throws: new System.Net.WebException("timeout"));
22 |
23 | var response = await client.Users.GetAll("gaming.stackexchange.com");
24 |
25 | Assert.IsFalse(response.Success);
26 | Assert.IsNull(response.Data);
27 | Assert.IsInstanceOfType(response.Error, typeof(System.Net.WebException));
28 | Assert.IsFalse(response.ReceivedApiResponse);
29 | Assert.IsNotNull(response.ApiUrl);
30 | Assert.IsNull(response.RawData);
31 | }
32 |
33 | [TestMethod]
34 | public async Task Test_response_debugging_properties()
35 | {
36 | var mock = new Mock("myappkey", null);
37 |
38 | //http://api.stackexchange.com/2.0/suggested-edits?pagesize=2&site=superuser
39 | mock.FakeGET(response: @"{""items"":[{""suggested_edit_id"":10345,""post_id"":410422,""post_type"":""question"",""comment"":""Removed unnecessary greetings"",""creation_date"":1333996736,""proposing_user"":{""user_id"":111438,""display_name"":""dnbrv"",""reputation"":348,""user_type"":""registered"",""profile_image"":""http://www.gravatar.com/avatar/0299470f4dcad8b4d79fd01c5dc7be4a?d=identicon&r=PG"",""link"":""http://superuser.com/users/111438/dnbrv""}},{""suggested_edit_id"":10344,""post_id"":410423,""post_type"":""question"",""comment"":""updated info"",""creation_date"":1333995585,""approval_date"":1333997046,""proposing_user"":{""user_id"":127397,""display_name"":""James Wilson"",""reputation"":3,""user_type"":""unregistered"",""profile_image"":""http://www.gravatar.com/avatar/ace280d5491b40c2645d856bf20337a3?d=identicon&r=PG"",""link"":""http://superuser.com/users/127397/james-wilson""}}],""quota_remaining"":262,""quota_max"":300,""has_more"":true}");
40 |
41 | var client = mock.Object;
42 |
43 | var response = await client.SuggestedEdits.GetAll("superuser", pagesize: 2);
44 | Assert.IsTrue(response.ApiUrl.Contains("site=superuser"));
45 | Assert.IsTrue(response.ApiUrl.Contains("pagesize=2"));
46 | Assert.IsTrue(response.ApiUrl.Contains("key=myappkey"));
47 |
48 | Assert.IsNotNull(response.RawData);
49 | }
50 |
51 | [TestMethod]
52 | public async Task Stack_Exchange_API_Exception_response()
53 | {
54 | var mock = new Mock(null, null);
55 |
56 | //http://api.stackexchange.com/2.0/inbox?access_token=foo
57 | mock.FakeGET(response: @"{""error_id"":405,""error_name"":""key_required"",""error_message"":""`key` is required when `access_token` is passed.""}");
58 |
59 | var client = mock.Object;
60 |
61 | var response = await client.Inbox.Get("foo");
62 |
63 | Assert.IsFalse(response.Success);
64 | Assert.IsTrue(response.ReceivedApiResponse);
65 | Assert.IsNotNull(response.RawData);
66 | Assert.IsInstanceOfType(response.Error, typeof(Exceptions.StackExchangeApiException));
67 | Assert.AreEqual(405, ((Exceptions.StackExchangeApiException)response.Error).ErrorId);
68 | Assert.AreEqual("key_required", ((Exceptions.StackExchangeApiException)response.Error).ErrorName);
69 | Assert.AreEqual("`key` is required when `access_token` is passed.", ((Exceptions.StackExchangeApiException)response.Error).ErrorMessage);
70 | Assert.IsNull(response.Data.Items);
71 | Assert.AreEqual(405, response.Data.ErrorId);
72 | Assert.AreEqual("key_required", response.Data.ErrorName);
73 | Assert.AreEqual("`key` is required when `access_token` is passed.", response.Data.ErrorMessage);
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/StacMan.Tests/TagMethodTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class TagMethodTests
14 | {
15 | [TestMethod]
16 | public async Task Tags_get_all_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/tags?page=3&pagesize=2&order=desc&sort=popular&site=gaming
21 | mock.FakeGET(response: @"{""items"":[{""name"":""league-of-legends"",""count"":768,""is_required"":false,""is_moderator_only"":false,""has_synonyms"":true},{""name"":""pc"",""count"":607,""is_required"":false,""is_moderator_only"":false,""has_synonyms"":false}],""quota_remaining"":-47478,""quota_max"":300,""has_more"":true}");
22 |
23 | var client = mock.Object;
24 |
25 | var result = await client.Tags.GetAll("gaming", page: 3, pagesize: 2, order: Order.Desc, sort: Tags.Sort.Popular);
26 | Assert.IsTrue(result.Success);
27 |
28 | var tag = result.Data.Items.Skip(1).First();
29 |
30 | Assert.AreEqual("pc", tag.Name);
31 | Assert.AreEqual(607, tag.Count);
32 | Assert.IsFalse(tag.IsRequired);
33 | Assert.IsFalse(tag.IsModeratorOnly);
34 | Assert.IsFalse(tag.HasSynonyms);
35 | Assert.IsNull(tag.UserId);
36 | Assert.IsNull(tag.LastActivityDate);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/StacMan.Tests/UserMethodTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class UserMethodTests
14 | {
15 | [TestMethod]
16 | public async Task Users_get_all_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/users?pagesize=1&order=desc&min=1&max=1000&sort=reputation&inname=doug&site=webapps
21 | mock.FakeGET(response: @"{""items"":[{""user_id"":183,""user_type"":""registered"",""creation_date"":1277932837,""display_name"":""Doug Harris"",""profile_image"":""http://www.gravatar.com/avatar/731e7de87c241fce562d03b23770b5cf?d=identicon&r=PG"",""reputation"":545,""reputation_change_day"":0,""reputation_change_week"":0,""reputation_change_month"":0,""reputation_change_quarter"":0,""reputation_change_year"":15,""age"":92,""last_access_date"":1332536617,""last_modified_date"":1332297406,""is_employee"":false,""link"":""http://webapps.stackexchange.com/users/183/doug-harris"",""website_url"":""http://delicious.com/dharris"",""location"":""Washington, DC"",""account_id"":46903,""badge_counts"":{""gold"":1,""silver"":4,""bronze"":8},""accept_rate"":25}],""quota_remaining"":-210785,""quota_max"":300,""has_more"":true}");
22 |
23 | var client = mock.Object;
24 |
25 | var result = await client.Users.GetAll("webapps", pagesize: 1, order: Order.Desc, min: 1, max: 1000, sort: Users.Sort.Reputation, inname: "doug");
26 | Assert.IsTrue(result.Success);
27 |
28 | var user = result.Data.Items.Single();
29 | Assert.AreEqual(183, user.UserId);
30 | Assert.AreEqual(Users.UserType.Registered, user.UserType);
31 | Assert.AreEqual("Doug Harris", user.DisplayName);
32 | Assert.AreEqual("http://www.gravatar.com/avatar/731e7de87c241fce562d03b23770b5cf?d=identicon&r=PG", user.ProfileImage);
33 | Assert.AreEqual(545, user.Reputation);
34 | Assert.AreEqual(0, user.ReputationChangeDay);
35 | Assert.AreEqual(0, user.ReputationChangeWeek);
36 | Assert.AreEqual(0, user.ReputationChangeMonth);
37 | Assert.AreEqual(0, user.ReputationChangeQuarter);
38 | Assert.AreEqual(15, user.ReputationChangeYear);
39 | Assert.AreEqual(92, user.Age);
40 | Assert.AreEqual(1332536617L.ToDateTime(), user.LastAccessDate);
41 | Assert.AreEqual(1332297406L.ToDateTime(), user.LastModifiedDate);
42 | Assert.IsFalse(user.IsEmployee);
43 | Assert.AreEqual("http://webapps.stackexchange.com/users/183/doug-harris", user.Link);
44 | Assert.AreEqual("http://delicious.com/dharris", user.WebsiteUrl);
45 | Assert.AreEqual("Washington, DC", user.Location);
46 | Assert.AreEqual(46903, user.AccountId);
47 | Assert.AreEqual(1, user.BadgeCounts.Gold);
48 | Assert.AreEqual(4, user.BadgeCounts.Silver);
49 | Assert.AreEqual(8, user.BadgeCounts.Bronze);
50 | Assert.AreEqual(25, user.AcceptRate);
51 | Assert.IsNull(user.TimedPenaltyDate);
52 | }
53 |
54 | [TestMethod]
55 | public async Task Users_get_associated_test()
56 | {
57 | var mock = new Mock(null, null);
58 |
59 | //http://api.stackexchange.com/2.0/users/1998/associated?pagesize=2
60 | mock.FakeGET(response: @"{""items"":[{""site_name"":""Stack Overflow"",""site_url"":""http://stackoverflow.com"",""user_id"":2749,""reputation"":4365,""account_id"":1998,""creation_date"":1219613204,""badge_counts"":{""gold"":1,""silver"":13,""bronze"":26},""last_access_date"":1334611626,""answer_count"":144,""question_count"":20},{""site_name"":""Server Fault"",""site_url"":""http://serverfault.com"",""user_id"":31532,""reputation"":101,""account_id"":1998,""creation_date"":1263334764,""badge_counts"":{""gold"":0,""silver"":0,""bronze"":3},""last_access_date"":1334610908,""answer_count"":0,""question_count"":0}],""quota_remaining"":-212787,""quota_max"":300,""has_more"":true}");
61 |
62 | var client = mock.Object;
63 |
64 | var result = await client.Users.GetAssociated(new int[] { 1998 }, pagesize: 2);
65 | Assert.IsTrue(result.Success);
66 |
67 | var networkUser = result.Data.Items.First();
68 | Assert.AreEqual("Stack Overflow", networkUser.SiteName);
69 | Assert.AreEqual("http://stackoverflow.com", networkUser.SiteUrl);
70 | Assert.AreEqual(2749, networkUser.UserId);
71 | Assert.AreEqual(4365, networkUser.Reputation);
72 | Assert.AreEqual(1998, networkUser.AccountId);
73 | Assert.AreEqual(1219613204L.ToDateTime(), networkUser.CreationDate);
74 | Assert.AreEqual(1, networkUser.BadgeCounts.Gold);
75 | Assert.AreEqual(13, networkUser.BadgeCounts.Silver);
76 | Assert.AreEqual(26, networkUser.BadgeCounts.Bronze);
77 | Assert.AreEqual(1334611626L.ToDateTime(), networkUser.LastAccessDate);
78 | Assert.AreEqual(144, networkUser.AnswerCount);
79 | Assert.AreEqual(20, networkUser.QuestionCount);
80 | Assert.AreEqual(default(StackExchange.StacMan.Users.UserType), networkUser.UserType);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/StacMan.Tests/Utilities/Assert2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 |
8 | namespace StackExchange.StacMan.Tests.Utilities
9 | {
10 | public static class Assert2
11 | {
12 | public static async Task Throws(Func func) where T : Exception
13 | {
14 | try
15 | {
16 | await func();
17 | Assert.Fail("An exception of type {0} was expected, but not thrown", typeof(T));
18 | }
19 | catch (T) { }
20 | }
21 |
22 | public static async Task ThrowsArgumentException(Func func, string paramName)
23 | {
24 | try
25 | {
26 | await func();
27 | Assert.Fail("An ArgumentException for param {0} was exepcted, but not thrown", paramName);
28 | }
29 | catch (ArgumentException ex)
30 | {
31 | if (ex.ParamName != paramName)
32 | Assert.Fail("An ArgumentException for param {0} was exepcted, but not thrown", paramName);
33 | }
34 | }
35 |
36 | public static async Task ThrowsArgumentNullException(Func func, string paramName)
37 | {
38 | try
39 | {
40 | await func();
41 | Assert.Fail("An ArgumentNullException for param {0} was exepcted, but not thrown", paramName);
42 | }
43 | catch (ArgumentNullException ex)
44 | {
45 | if (ex.ParamName != paramName)
46 | Assert.Fail("An ArgumentNullException for param {0} was exepcted, but not thrown", paramName);
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/StacMan.Tests/Utilities/ExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Moq;
6 |
7 | namespace StackExchange.StacMan.Tests.Utilities
8 | {
9 | public static class ExtensionMethods
10 | {
11 | private static readonly DateTime UnixEpochDateTimeUtc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
12 |
13 | public static DateTime ToDateTime(this long secondsSince1970)
14 | {
15 | return UnixEpochDateTimeUtc.AddSeconds(secondsSince1970);
16 | }
17 |
18 | public static void FakeGET(this Mock mock, string response = null, Exception throws = null)
19 | {
20 | mock.Setup(c => c.FetchApiResponseWithGET(It.IsAny(), It.IsAny>(), It.IsAny>()))
21 | .Callback, Action>((url, success, error) =>
22 | {
23 | if (throws != null)
24 | error(throws);
25 | else
26 | success(response);
27 | });
28 | }
29 |
30 | public static void FakeGETForUrlPattern(this Mock mock, string regex, string response = null, Exception throws = null)
31 | {
32 | mock.Setup(c => c.FetchApiResponseWithGET(It.IsRegex(regex), It.IsAny>(), It.IsAny>()))
33 | .Callback, Action>((url, success, error) =>
34 | {
35 | if (throws != null)
36 | error(throws);
37 | else
38 | success(response);
39 | });
40 | }
41 |
42 | public static void FakePOST(this Mock mock, string response = null, Exception throws = null)
43 | {
44 | mock.Setup(c => c.FetchApiResponseWithPOST(It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny>()))
45 | .Callback, Action>((url, data, success, error) =>
46 | {
47 | if (throws != null)
48 | error(throws);
49 | else
50 | success(response);
51 | });
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/StacMan.Tests/ValidationTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class ValidationTests
14 | {
15 | public ValidationTests()
16 | {
17 | var mock = new Mock(null, null);
18 | mock.FakeGET(response: "{}");
19 | Client = mock.Object;
20 | }
21 |
22 | private readonly StacManClient Client;
23 |
24 | [TestMethod]
25 | public async Task Invalidates_null_or_empty_site()
26 | {
27 | await Client.Users.GetByIds("stackoverflow", new int[] { 1, 2, 3 });
28 | await Assert2.ThrowsArgumentNullException(async () => await Client.Users.GetByIds(null, new int[] { 1, 2, 3 }), "site");
29 | await Assert2.ThrowsArgumentException(async () => await Client.Users.GetByIds(String.Empty, new int[] { 1, 2, 3 }), "site");
30 | }
31 |
32 | [TestMethod]
33 | public async Task Invalidates_null_or_empty_vector()
34 | {
35 | await Client.Users.GetByIds("stackoverflow", new int[] { 1, 2, 3 });
36 | await Assert2.ThrowsArgumentNullException(async () => await Client.Users.GetByIds("stackoverflow", null), "ids");
37 | await Assert2.ThrowsArgumentException(async () => await Client.Users.GetByIds("stackoverflow", new int[0]), "ids");
38 |
39 | await Client.Filters.Read(new string[] { "foo", "bar", "baz" });
40 | await Assert2.ThrowsArgumentNullException(async () => await Client.Filters.Read(null), "filters");
41 | await Assert2.ThrowsArgumentException(async () => await Client.Filters.Read(new string[0]), "filters");
42 | }
43 |
44 | [TestMethod]
45 | public async Task Invalidates_bad_paging()
46 | {
47 | await Client.Users.GetByIds("stackoverflow", new int[] { 1, 2, 3 }, page: 1, pagesize: 0);
48 | await Assert2.ThrowsArgumentException(async () => await Client.Users.GetByIds("stackoverflow", new int[] { 1, 2, 3 }, page: 0, pagesize: 10), "page");
49 | await Assert2.ThrowsArgumentException(async () => await Client.Users.GetByIds("stackoverflow", new int[] { 1, 2, 3 }, page: 10, pagesize: -1), "pagesize");
50 | }
51 |
52 | [TestMethod]
53 | public async Task Invalidates_bad_sorts()
54 | {
55 | var today = DateTime.UtcNow;
56 | var yesterday = today.AddDays(-1);
57 |
58 | await Client.Questions.GetAll("stackoverflow");
59 | await Client.Questions.GetAll("stackoverflow", mindate: yesterday);
60 | await Client.Questions.GetAll("stackoverflow", maxdate: today);
61 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", min: 1), "min");
62 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", max: 1), "max");
63 |
64 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity);
65 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity, mindate: yesterday);
66 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity, maxdate: today);
67 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity, min: 1), "min");
68 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity, max: 1), "max");
69 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Activity, mindate: yesterday, maxdate: today, max: 1), "max");
70 |
71 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes);
72 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes, min: 1);
73 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes, max: 1);
74 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes, mindate: yesterday), "mindate");
75 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes, maxdate: today), "maxdate");
76 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Votes, min: 1, max: 2, maxdate: today), "maxdate");
77 |
78 | await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Week);
79 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Week, mindate: yesterday), "mindate");
80 | await Assert2.ThrowsArgumentException(async () => await Client.Questions.GetAll("stackoverflow", sort: Questions.AllSort.Week, min: 1), "min");
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/StacMan.Tests/WrapperTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using StackExchange.StacMan.Tests.Utilities;
7 | using Microsoft.VisualStudio.TestTools.UnitTesting;
8 | using Moq;
9 |
10 | namespace StackExchange.StacMan.Tests
11 | {
12 | [TestClass]
13 | public class WrapperTests
14 | {
15 | [TestMethod]
16 | public async Task Wrapper_fields_test()
17 | {
18 | var mock = new Mock(null, null);
19 |
20 | //http://api.stackexchange.com/2.0/filters/!*bOpvmsY(F)
21 | mock.FakeGETForUrlPattern("filters", response: @"{""items"":[{""filter"":""!*bOpvmsY(F)"",""included_fields"":["".backoff"","".error_id"","".error_message"","".error_name"","".has_more"","".items"","".page"","".page_size"","".quota_max"","".quota_remaining"","".total"","".type"",""badge.badge_id""],""filter_type"":""safe""}],""quota_remaining"":271,""quota_max"":300,""has_more"":false}");
22 |
23 | //http://api.stackexchange.com/2.0/badges?page=2&pagesize=5&site=stackoverflow&filter=!*bOpvmsY(F)
24 | mock.FakeGETForUrlPattern("badges", @"{""total"":1713,""page_size"":5,""page"":2,""type"":""badge"",""items"":[{""badge_id"":460},{""badge_id"":461},{""badge_id"":462},{""badge_id"":463},{""badge_id"":464}],""quota_remaining"":273,""quota_max"":300,""has_more"":true}");
25 |
26 | var client = mock.Object;
27 | var result = await client.Badges.GetAll("stackoverflow", page: 2, pagesize: 5, filter: "!*bOpvmsY(F)");
28 | var wrapper = result.Data;
29 |
30 | Assert.AreEqual(1713, wrapper.Total);
31 | Assert.AreEqual(5, wrapper.PageSize);
32 | Assert.AreEqual(2, wrapper.Page);
33 | Assert.AreEqual(5, wrapper.Items.Length);
34 | Assert.AreEqual("badge", wrapper.Type);
35 | Assert.AreEqual(273, wrapper.QuotaRemaining);
36 | Assert.AreEqual(300, wrapper.QuotaMax);
37 | Assert.AreEqual(true, wrapper.HasMore);
38 | Assert.IsNull(wrapper.Backoff);
39 | Assert.IsNull(wrapper.ErrorId);
40 | Assert.IsNull(wrapper.ErrorName);
41 | Assert.IsNull(wrapper.ErrorMessage);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/StacMan.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.2.32505.173
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StacMan", "StacMan\StacMan.csproj", "{3C310AC6-6229-41FB-B33F-8381CF4FECBF}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StacMan.Tests", "StacMan.Tests\StacMan.Tests.csproj", "{5FBD3A5B-93AE-43B7-9566-C7D08A71C8E9}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{940A5141-7F86-40E6-BB3D-046EE0A79FB7}"
11 | ProjectSection(SolutionItems) = preProject
12 | Local.testsettings = Local.testsettings
13 | README.md = README.md
14 | StacMan.vsmdi = StacMan.vsmdi
15 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
16 | EndProjectSection
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {3C310AC6-6229-41FB-B33F-8381CF4FECBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {3C310AC6-6229-41FB-B33F-8381CF4FECBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {3C310AC6-6229-41FB-B33F-8381CF4FECBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {3C310AC6-6229-41FB-B33F-8381CF4FECBF}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {5FBD3A5B-93AE-43B7-9566-C7D08A71C8E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {5FBD3A5B-93AE-43B7-9566-C7D08A71C8E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {5FBD3A5B-93AE-43B7-9566-C7D08A71C8E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {5FBD3A5B-93AE-43B7-9566-C7D08A71C8E9}.Release|Any CPU.Build.0 = Release|Any CPU
32 | EndGlobalSection
33 | GlobalSection(SolutionProperties) = preSolution
34 | HideSolutionNode = FALSE
35 | EndGlobalSection
36 | GlobalSection(ExtensibilityGlobals) = postSolution
37 | SolutionGuid = {03B8E1E4-6E0A-475B-A79E-5174D4ABB49A}
38 | EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.Interception.2.1.505.0\lib\NET35
39 | EndGlobalSection
40 | GlobalSection(TestCaseManagementSettings) = postSolution
41 | CategoryFile = StacMan.vsmdi
42 | EndGlobalSection
43 | EndGlobal
44 |
--------------------------------------------------------------------------------
/StacMan.vsmdi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/StacMan/Answers/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Answers
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// score
22 | ///
23 | [Sort(SortType.Integer)]
24 | Votes
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/ApiUrlBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.Specialized;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Web;
7 |
8 | namespace StackExchange.StacMan
9 | {
10 | internal class ApiUrlBuilder
11 | {
12 | public ApiUrlBuilder(string apiVersion, string relativeUrl, bool useHttps = false)
13 | {
14 | BaseUrl = String.Format("{0}://api.stackexchange.com/{1}{2}{3}", useHttps ? "https" : "http", apiVersion, relativeUrl.StartsWith("/") ? "" : "/", relativeUrl);
15 | QueryStringParameters = new NameValueCollection();
16 | }
17 |
18 | public readonly string BaseUrl;
19 | private readonly NameValueCollection QueryStringParameters;
20 |
21 | public void AddParameter(string name, object value)
22 | {
23 | if (value != null)
24 | QueryStringParameters.Add(name, value.ToString());
25 | }
26 |
27 | public void AddParameter(string name, DateTime? dt)
28 | {
29 | if (dt.HasValue)
30 | AddParameter(name, dt.Value.ToUnixTime());
31 | }
32 |
33 | public void AddParameter(string name, IEnumerable values)
34 | {
35 | if (values != null && values.Any())
36 | AddParameter(name, String.Join(";", values));
37 | }
38 |
39 | public string QueryString()
40 | {
41 | return String.Join("&", QueryStringParameters.AllKeys.Select(key => String.Format("{0}={1}", HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(QueryStringParameters[key]))));
42 | }
43 |
44 | public override string ToString()
45 | {
46 | var url = BaseUrl;
47 |
48 | if (QueryStringParameters.Count > 0)
49 | url += "?" + QueryString();
50 |
51 | return url;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/StacMan/Badges/AllSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Badges
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum AllSort
7 | {
8 | ///
9 | /// rank
10 | ///
11 | [Sort(SortType.BadgeRank)]
12 | Rank,
13 |
14 | ///
15 | /// name
16 | ///
17 | [Sort(SortType.String)]
18 | Name,
19 |
20 | ///
21 | /// badge_type
22 | ///
23 | [Sort(SortType.BadgeType)]
24 | Type
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/Badges/BadgeType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Badges
2 | {
3 | ///
4 | /// badge_type
5 | ///
6 | public enum BadgeType
7 | {
8 | ///
9 | /// name
10 | ///
11 | Named,
12 |
13 | ///
14 | /// tag_based
15 | ///
16 | TagBased
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/StacMan/Badges/Rank.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Badges
2 | {
3 | ///
4 | /// rank
5 | ///
6 | public enum Rank
7 | {
8 | ///
9 | /// gold
10 | ///
11 | Gold,
12 |
13 | ///
14 | /// silver
15 | ///
16 | Silver,
17 |
18 | ///
19 | /// bronze
20 | ///
21 | Bronze
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/StacMan/Badges/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Badges
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// rank
10 | ///
11 | [Sort(SortType.BadgeRank)]
12 | Rank,
13 |
14 | ///
15 | /// name
16 | ///
17 | [Sort(SortType.String)]
18 | Name
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/StacMan/Badges/UserSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Badges
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum UserSort
7 | {
8 | ///
9 | /// rank
10 | ///
11 | [Sort(SortType.BadgeRank)]
12 | Rank,
13 |
14 | ///
15 | /// name
16 | ///
17 | [Sort(SortType.String)]
18 | Name,
19 |
20 | ///
21 | /// badge_type
22 | ///
23 | [Sort(SortType.BadgeType)]
24 | Type,
25 |
26 | ///
27 | /// badge award date
28 | ///
29 | [Sort(SortType.DateTime)]
30 | Awarded
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/StacMan/Codegen/AccessToken.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan AccessToken, corresponding to Stack Exchange API v2's access_token type
13 | /// http://api.stackexchange.com/docs/types/access-token
14 | ///
15 | public partial class AccessToken : StacManType
16 | {
17 | ///
18 | /// access_token
19 | ///
20 | [Field("access_token")]
21 | public string AccessTokenName { get; internal set; }
22 |
23 | ///
24 | /// account_id
25 | ///
26 | [Field("account_id")]
27 | public int AccountId { get; internal set; }
28 |
29 | ///
30 | /// expires_on_date
31 | ///
32 | [Field("expires_on_date")]
33 | public DateTime? ExpiresOnDate { get; internal set; }
34 |
35 | ///
36 | /// scope
37 | ///
38 | [Field("scope")]
39 | public string[] Scope { get; internal set; }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/StacMan/Codegen/AccountMerge.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan AccountMerge, corresponding to Stack Exchange API v2's account_merge type
13 | /// http://api.stackexchange.com/docs/types/account-merge
14 | ///
15 | public partial class AccountMerge : StacManType
16 | {
17 | ///
18 | /// merge_date -- introduced in API version 2.1
19 | ///
20 | [Field("merge_date")]
21 | public DateTime MergeDate { get; internal set; }
22 |
23 | ///
24 | /// new_account_id -- introduced in API version 2.1
25 | ///
26 | [Field("new_account_id")]
27 | public int NewAccountId { get; internal set; }
28 |
29 | ///
30 | /// old_account_id -- introduced in API version 2.1
31 | ///
32 | [Field("old_account_id")]
33 | public int OldAccountId { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Answer.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Answer, corresponding to Stack Exchange API v2's answer type
13 | /// http://api.stackexchange.com/docs/types/answer
14 | ///
15 | public partial class Answer : StacManType
16 | {
17 | ///
18 | /// answer_id
19 | ///
20 | [Field("answer_id")]
21 | public int AnswerId { get; internal set; }
22 |
23 | ///
24 | /// body
25 | ///
26 | [Field("body")]
27 | public string Body { get; internal set; }
28 |
29 | ///
30 | /// comments
31 | ///
32 | [Field("comments")]
33 | public Comment[] Comments { get; internal set; }
34 |
35 | ///
36 | /// community_owned_date
37 | ///
38 | [Field("community_owned_date")]
39 | public DateTime? CommunityOwnedDate { get; internal set; }
40 |
41 | ///
42 | /// creation_date
43 | ///
44 | [Field("creation_date")]
45 | public DateTime CreationDate { get; internal set; }
46 |
47 | ///
48 | /// down_vote_count
49 | ///
50 | [Field("down_vote_count")]
51 | public int DownVoteCount { get; internal set; }
52 |
53 | ///
54 | /// is_accepted
55 | ///
56 | [Field("is_accepted")]
57 | public bool IsAccepted { get; internal set; }
58 |
59 | ///
60 | /// last_activity_date
61 | ///
62 | [Field("last_activity_date")]
63 | public DateTime LastActivityDate { get; internal set; }
64 |
65 | ///
66 | /// last_edit_date
67 | ///
68 | [Field("last_edit_date")]
69 | public DateTime? LastEditDate { get; internal set; }
70 |
71 | ///
72 | /// link
73 | ///
74 | [Field("link")]
75 | public string Link { get; internal set; }
76 |
77 | ///
78 | /// locked_date
79 | ///
80 | [Field("locked_date")]
81 | public DateTime? LockedDate { get; internal set; }
82 |
83 | ///
84 | /// owner
85 | ///
86 | [Field("owner")]
87 | public ShallowUser Owner { get; internal set; }
88 |
89 | ///
90 | /// question_id
91 | ///
92 | [Field("question_id")]
93 | public int QuestionId { get; internal set; }
94 |
95 | ///
96 | /// score
97 | ///
98 | [Field("score")]
99 | public int Score { get; internal set; }
100 |
101 | ///
102 | /// tags -- introduced in API version 2.1
103 | ///
104 | [Field("tags")]
105 | public string[] Tags { get; internal set; }
106 |
107 | ///
108 | /// title
109 | ///
110 | [Field("title")]
111 | public string Title { get; internal set; }
112 |
113 | ///
114 | /// up_vote_count
115 | ///
116 | [Field("up_vote_count")]
117 | public int UpVoteCount { get; internal set; }
118 |
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Badge.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Badge, corresponding to Stack Exchange API v2's badge type
13 | /// http://api.stackexchange.com/docs/types/badge
14 | ///
15 | public partial class Badge : StacManType
16 | {
17 | ///
18 | /// award_count
19 | ///
20 | [Field("award_count")]
21 | public int AwardCount { get; internal set; }
22 |
23 | ///
24 | /// badge_id
25 | ///
26 | [Field("badge_id")]
27 | public int BadgeId { get; internal set; }
28 |
29 | ///
30 | /// badge_type
31 | ///
32 | [Field("badge_type")]
33 | public Badges.BadgeType BadgeType { get; internal set; }
34 |
35 | ///
36 | /// description
37 | ///
38 | [Field("description")]
39 | public string Description { get; internal set; }
40 |
41 | ///
42 | /// link
43 | ///
44 | [Field("link")]
45 | public string Link { get; internal set; }
46 |
47 | ///
48 | /// name
49 | ///
50 | [Field("name")]
51 | public string Name { get; internal set; }
52 |
53 | ///
54 | /// rank
55 | ///
56 | [Field("rank")]
57 | public Badges.Rank Rank { get; internal set; }
58 |
59 | ///
60 | /// user
61 | ///
62 | [Field("user")]
63 | public ShallowUser User { get; internal set; }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/StacMan/Codegen/BadgeCount.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan BadgeCount, corresponding to Stack Exchange API v2's badge_count type
13 | /// http://api.stackexchange.com/docs/types/badge-count
14 | ///
15 | public partial class BadgeCount : StacManType
16 | {
17 | ///
18 | /// bronze
19 | ///
20 | [Field("bronze")]
21 | public int Bronze { get; internal set; }
22 |
23 | ///
24 | /// gold
25 | ///
26 | [Field("gold")]
27 | public int Gold { get; internal set; }
28 |
29 | ///
30 | /// silver
31 | ///
32 | [Field("silver")]
33 | public int Silver { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Comment.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Comment, corresponding to Stack Exchange API v2's comment type
13 | /// http://api.stackexchange.com/docs/types/comment
14 | ///
15 | public partial class Comment : StacManType
16 | {
17 | ///
18 | /// body
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// body_markdown -- introduced in API version 2.1
25 | ///
26 | [Field("body_markdown")]
27 | public string BodyMarkdown { get; internal set; }
28 |
29 | ///
30 | /// comment_id
31 | ///
32 | [Field("comment_id")]
33 | public int CommentId { get; internal set; }
34 |
35 | ///
36 | /// creation_date
37 | ///
38 | [Field("creation_date")]
39 | public DateTime CreationDate { get; internal set; }
40 |
41 | ///
42 | /// edited
43 | ///
44 | [Field("edited")]
45 | public bool Edited { get; internal set; }
46 |
47 | ///
48 | /// link
49 | ///
50 | [Field("link")]
51 | public string Link { get; internal set; }
52 |
53 | ///
54 | /// owner
55 | ///
56 | [Field("owner")]
57 | public ShallowUser Owner { get; internal set; }
58 |
59 | ///
60 | /// post_id
61 | ///
62 | [Field("post_id")]
63 | public int PostId { get; internal set; }
64 |
65 | ///
66 | /// post_type
67 | ///
68 | [Field("post_type")]
69 | public Posts.PostType PostType { get; internal set; }
70 |
71 | ///
72 | /// reply_to_user
73 | ///
74 | [Field("reply_to_user")]
75 | public ShallowUser ReplyToUser { get; internal set; }
76 |
77 | ///
78 | /// score
79 | ///
80 | [Field("score")]
81 | public int Score { get; internal set; }
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Error.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Error, corresponding to Stack Exchange API v2's error type
13 | /// http://api.stackexchange.com/docs/types/error
14 | ///
15 | public partial class Error : StacManType
16 | {
17 | ///
18 | /// description
19 | ///
20 | [Field("description")]
21 | public string Description { get; internal set; }
22 |
23 | ///
24 | /// error_id
25 | ///
26 | [Field("error_id")]
27 | public int ErrorId { get; internal set; }
28 |
29 | ///
30 | /// error_name
31 | ///
32 | [Field("error_name")]
33 | public string ErrorName { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Event.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Event, corresponding to Stack Exchange API v2's event type
13 | /// http://api.stackexchange.com/docs/types/event
14 | ///
15 | public partial class Event : StacManType
16 | {
17 | ///
18 | /// creation_date
19 | ///
20 | [Field("creation_date")]
21 | public DateTime CreationDate { get; internal set; }
22 |
23 | ///
24 | /// event_id
25 | ///
26 | [Field("event_id")]
27 | public int EventId { get; internal set; }
28 |
29 | ///
30 | /// event_type
31 | ///
32 | [Field("event_type")]
33 | public Events.EventType EventType { get; internal set; }
34 |
35 | ///
36 | /// excerpt
37 | ///
38 | [Field("excerpt")]
39 | public string Excerpt { get; internal set; }
40 |
41 | ///
42 | /// link
43 | ///
44 | [Field("link")]
45 | public string Link { get; internal set; }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Filter.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Filter, corresponding to Stack Exchange API v2's filter type
13 | /// http://api.stackexchange.com/docs/types/filter
14 | ///
15 | public partial class Filter : StacManType
16 | {
17 | ///
18 | /// filter
19 | ///
20 | [Field("filter")]
21 | public string FilterName { get; internal set; }
22 |
23 | ///
24 | /// filter_type
25 | ///
26 | [Field("filter_type")]
27 | public Filters.FilterType FilterType { get; internal set; }
28 |
29 | ///
30 | /// included_fields
31 | ///
32 | [Field("included_fields")]
33 | public string[] IncludedFields { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/InboxItem.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan InboxItem, corresponding to Stack Exchange API v2's inbox_item type
13 | /// http://api.stackexchange.com/docs/types/inbox-item
14 | ///
15 | public partial class InboxItem : StacManType
16 | {
17 | ///
18 | /// answer_id
19 | ///
20 | [Field("answer_id")]
21 | public int? AnswerId { get; internal set; }
22 |
23 | ///
24 | /// body
25 | ///
26 | [Field("body")]
27 | public string Body { get; internal set; }
28 |
29 | ///
30 | /// comment_id
31 | ///
32 | [Field("comment_id")]
33 | public int? CommentId { get; internal set; }
34 |
35 | ///
36 | /// creation_date
37 | ///
38 | [Field("creation_date")]
39 | public DateTime CreationDate { get; internal set; }
40 |
41 | ///
42 | /// is_unread
43 | ///
44 | [Field("is_unread")]
45 | public bool IsUnread { get; internal set; }
46 |
47 | ///
48 | /// item_type
49 | ///
50 | [Field("item_type")]
51 | public InboxItems.ItemType ItemType { get; internal set; }
52 |
53 | ///
54 | /// link
55 | ///
56 | [Field("link")]
57 | public string Link { get; internal set; }
58 |
59 | ///
60 | /// question_id
61 | ///
62 | [Field("question_id")]
63 | public int? QuestionId { get; internal set; }
64 |
65 | ///
66 | /// site
67 | ///
68 | [Field("site")]
69 | public Site Site { get; internal set; }
70 |
71 | ///
72 | /// title
73 | ///
74 | [Field("title")]
75 | public string Title { get; internal set; }
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Info.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Info, corresponding to Stack Exchange API v2's info type
13 | /// http://api.stackexchange.com/docs/types/info
14 | ///
15 | public partial class Info : StacManType
16 | {
17 | ///
18 | /// answers_per_minute
19 | ///
20 | [Field("answers_per_minute")]
21 | public decimal AnswersPerMinute { get; internal set; }
22 |
23 | ///
24 | /// api_revision
25 | ///
26 | [Field("api_revision")]
27 | public string ApiRevision { get; internal set; }
28 |
29 | ///
30 | /// badges_per_minute
31 | ///
32 | [Field("badges_per_minute")]
33 | public decimal BadgesPerMinute { get; internal set; }
34 |
35 | ///
36 | /// new_active_users
37 | ///
38 | [Field("new_active_users")]
39 | public int NewActiveUsers { get; internal set; }
40 |
41 | ///
42 | /// questions_per_minute
43 | ///
44 | [Field("questions_per_minute")]
45 | public decimal QuestionsPerMinute { get; internal set; }
46 |
47 | ///
48 | /// site
49 | ///
50 | [Field("site")]
51 | public Site Site { get; internal set; }
52 |
53 | ///
54 | /// total_accepted
55 | ///
56 | [Field("total_accepted")]
57 | public int TotalAccepted { get; internal set; }
58 |
59 | ///
60 | /// total_answers
61 | ///
62 | [Field("total_answers")]
63 | public int TotalAnswers { get; internal set; }
64 |
65 | ///
66 | /// total_badges
67 | ///
68 | [Field("total_badges")]
69 | public int TotalBadges { get; internal set; }
70 |
71 | ///
72 | /// total_comments
73 | ///
74 | [Field("total_comments")]
75 | public int TotalComments { get; internal set; }
76 |
77 | ///
78 | /// total_questions
79 | ///
80 | [Field("total_questions")]
81 | public int TotalQuestions { get; internal set; }
82 |
83 | ///
84 | /// total_unanswered
85 | ///
86 | [Field("total_unanswered")]
87 | public int TotalUnanswered { get; internal set; }
88 |
89 | ///
90 | /// total_users
91 | ///
92 | [Field("total_users")]
93 | public int TotalUsers { get; internal set; }
94 |
95 | ///
96 | /// total_votes
97 | ///
98 | [Field("total_votes")]
99 | public int TotalVotes { get; internal set; }
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Methods.ignore:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 |
8 |
--------------------------------------------------------------------------------
/StacMan/Codegen/MigrationInfo.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan MigrationInfo, corresponding to Stack Exchange API v2's migration_info type
13 | /// http://api.stackexchange.com/docs/types/migration-info
14 | ///
15 | public partial class MigrationInfo : StacManType
16 | {
17 | ///
18 | /// on_date
19 | ///
20 | [Field("on_date")]
21 | public DateTime OnDate { get; internal set; }
22 |
23 | ///
24 | /// other_site
25 | ///
26 | [Field("other_site")]
27 | public Site OtherSite { get; internal set; }
28 |
29 | ///
30 | /// question_id
31 | ///
32 | [Field("question_id")]
33 | public int QuestionId { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/NetworkUser.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan NetworkUser, corresponding to Stack Exchange API v2's network_user type
13 | /// http://api.stackexchange.com/docs/types/network-user
14 | ///
15 | public partial class NetworkUser : StacManType
16 | {
17 | ///
18 | /// account_id
19 | ///
20 | [Field("account_id")]
21 | public int AccountId { get; internal set; }
22 |
23 | ///
24 | /// answer_count
25 | ///
26 | [Field("answer_count")]
27 | public int AnswerCount { get; internal set; }
28 |
29 | ///
30 | /// badge_counts
31 | ///
32 | [Field("badge_counts")]
33 | public BadgeCount BadgeCounts { get; internal set; }
34 |
35 | ///
36 | /// creation_date
37 | ///
38 | [Field("creation_date")]
39 | public DateTime CreationDate { get; internal set; }
40 |
41 | ///
42 | /// last_access_date
43 | ///
44 | [Field("last_access_date")]
45 | public DateTime LastAccessDate { get; internal set; }
46 |
47 | ///
48 | /// question_count
49 | ///
50 | [Field("question_count")]
51 | public int QuestionCount { get; internal set; }
52 |
53 | ///
54 | /// reputation
55 | ///
56 | [Field("reputation")]
57 | public int Reputation { get; internal set; }
58 |
59 | ///
60 | /// site_name
61 | ///
62 | [Field("site_name")]
63 | public string SiteName { get; internal set; }
64 |
65 | ///
66 | /// site_url
67 | ///
68 | [Field("site_url")]
69 | public string SiteUrl { get; internal set; }
70 |
71 | ///
72 | /// user_id
73 | ///
74 | [Field("user_id")]
75 | public int UserId { get; internal set; }
76 |
77 | ///
78 | /// user_type
79 | ///
80 | [Field("user_type")]
81 | public Users.UserType UserType { get; internal set; }
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Notice.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Notice, corresponding to Stack Exchange API v2's notice type
13 | /// http://api.stackexchange.com/docs/types/notice
14 | ///
15 | public partial class Notice : StacManType
16 | {
17 | ///
18 | /// body -- introduced in API version 2.1
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// creation_date -- introduced in API version 2.1
25 | ///
26 | [Field("creation_date")]
27 | public DateTime CreationDate { get; internal set; }
28 |
29 | ///
30 | /// owner_user_id -- introduced in API version 2.1
31 | ///
32 | [Field("owner_user_id")]
33 | public int OwnerUserId { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Notification.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Notification, corresponding to Stack Exchange API v2's notification type
13 | /// http://api.stackexchange.com/docs/types/notification
14 | ///
15 | public partial class Notification : StacManType
16 | {
17 | ///
18 | /// body -- introduced in API version 2.1
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// creation_date -- introduced in API version 2.1
25 | ///
26 | [Field("creation_date")]
27 | public DateTime CreationDate { get; internal set; }
28 |
29 | ///
30 | /// is_unread -- introduced in API version 2.1
31 | ///
32 | [Field("is_unread")]
33 | public bool IsUnread { get; internal set; }
34 |
35 | ///
36 | /// notification_type -- introduced in API version 2.1
37 | ///
38 | [Field("notification_type")]
39 | public Notifications.NotificationType NotificationType { get; internal set; }
40 |
41 | ///
42 | /// post_id -- introduced in API version 2.1
43 | ///
44 | [Field("post_id")]
45 | public int? PostId { get; internal set; }
46 |
47 | ///
48 | /// site -- introduced in API version 2.1
49 | ///
50 | [Field("site")]
51 | public Site Site { get; internal set; }
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Post.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Post, corresponding to Stack Exchange API v2's post type
13 | /// http://api.stackexchange.com/docs/types/post
14 | ///
15 | public partial class Post : StacManType
16 | {
17 | ///
18 | /// body
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// comments
25 | ///
26 | [Field("comments")]
27 | public Comment[] Comments { get; internal set; }
28 |
29 | ///
30 | /// creation_date
31 | ///
32 | [Field("creation_date")]
33 | public DateTime CreationDate { get; internal set; }
34 |
35 | ///
36 | /// down_vote_count
37 | ///
38 | [Field("down_vote_count")]
39 | public int DownVoteCount { get; internal set; }
40 |
41 | ///
42 | /// last_activity_date
43 | ///
44 | [Field("last_activity_date")]
45 | public DateTime LastActivityDate { get; internal set; }
46 |
47 | ///
48 | /// last_edit_date
49 | ///
50 | [Field("last_edit_date")]
51 | public DateTime? LastEditDate { get; internal set; }
52 |
53 | ///
54 | /// link -- introduced in API version 2.1
55 | ///
56 | [Field("link")]
57 | public string Link { get; internal set; }
58 |
59 | ///
60 | /// owner
61 | ///
62 | [Field("owner")]
63 | public ShallowUser Owner { get; internal set; }
64 |
65 | ///
66 | /// post_id
67 | ///
68 | [Field("post_id")]
69 | public int PostId { get; internal set; }
70 |
71 | ///
72 | /// post_type
73 | ///
74 | [Field("post_type")]
75 | public Posts.PostType PostType { get; internal set; }
76 |
77 | ///
78 | /// score
79 | ///
80 | [Field("score")]
81 | public int Score { get; internal set; }
82 |
83 | ///
84 | /// up_vote_count
85 | ///
86 | [Field("up_vote_count")]
87 | public int UpVoteCount { get; internal set; }
88 |
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Privilege.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Privilege, corresponding to Stack Exchange API v2's privilege type
13 | /// http://api.stackexchange.com/docs/types/privilege
14 | ///
15 | public partial class Privilege : StacManType
16 | {
17 | ///
18 | /// description
19 | ///
20 | [Field("description")]
21 | public string Description { get; internal set; }
22 |
23 | ///
24 | /// reputation
25 | ///
26 | [Field("reputation")]
27 | public int Reputation { get; internal set; }
28 |
29 | ///
30 | /// short_description
31 | ///
32 | [Field("short_description")]
33 | public string ShortDescription { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Question.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Question, corresponding to Stack Exchange API v2's question type
13 | /// http://api.stackexchange.com/docs/types/question
14 | ///
15 | public partial class Question : StacManType
16 | {
17 | ///
18 | /// accepted_answer_id
19 | ///
20 | [Field("accepted_answer_id")]
21 | public int? AcceptedAnswerId { get; internal set; }
22 |
23 | ///
24 | /// answer_count
25 | ///
26 | [Field("answer_count")]
27 | public int AnswerCount { get; internal set; }
28 |
29 | ///
30 | /// answers
31 | ///
32 | [Field("answers")]
33 | public Answer[] Answers { get; internal set; }
34 |
35 | ///
36 | /// body
37 | ///
38 | [Field("body")]
39 | public string Body { get; internal set; }
40 |
41 | ///
42 | /// bounty_amount
43 | ///
44 | [Field("bounty_amount")]
45 | public int? BountyAmount { get; internal set; }
46 |
47 | ///
48 | /// bounty_closes_date
49 | ///
50 | [Field("bounty_closes_date")]
51 | public DateTime? BountyClosesDate { get; internal set; }
52 |
53 | ///
54 | /// close_vote_count -- introduced in API version 2.1
55 | ///
56 | [Field("close_vote_count")]
57 | public int CloseVoteCount { get; internal set; }
58 |
59 | ///
60 | /// closed_date
61 | ///
62 | [Field("closed_date")]
63 | public DateTime? ClosedDate { get; internal set; }
64 |
65 | ///
66 | /// closed_reason
67 | ///
68 | [Field("closed_reason")]
69 | public string ClosedReason { get; internal set; }
70 |
71 | ///
72 | /// comments
73 | ///
74 | [Field("comments")]
75 | public Comment[] Comments { get; internal set; }
76 |
77 | ///
78 | /// community_owned_date
79 | ///
80 | [Field("community_owned_date")]
81 | public DateTime? CommunityOwnedDate { get; internal set; }
82 |
83 | ///
84 | /// creation_date
85 | ///
86 | [Field("creation_date")]
87 | public DateTime CreationDate { get; internal set; }
88 |
89 | ///
90 | /// delete_vote_count -- introduced in API version 2.1
91 | ///
92 | [Field("delete_vote_count")]
93 | public int DeleteVoteCount { get; internal set; }
94 |
95 | ///
96 | /// down_vote_count
97 | ///
98 | [Field("down_vote_count")]
99 | public int DownVoteCount { get; internal set; }
100 |
101 | ///
102 | /// favorite_count
103 | ///
104 | [Field("favorite_count")]
105 | public int FavoriteCount { get; internal set; }
106 |
107 | ///
108 | /// is_answered
109 | ///
110 | [Field("is_answered")]
111 | public bool IsAnswered { get; internal set; }
112 |
113 | ///
114 | /// last_activity_date
115 | ///
116 | [Field("last_activity_date")]
117 | public DateTime LastActivityDate { get; internal set; }
118 |
119 | ///
120 | /// last_edit_date
121 | ///
122 | [Field("last_edit_date")]
123 | public DateTime? LastEditDate { get; internal set; }
124 |
125 | ///
126 | /// link
127 | ///
128 | [Field("link")]
129 | public string Link { get; internal set; }
130 |
131 | ///
132 | /// locked_date
133 | ///
134 | [Field("locked_date")]
135 | public DateTime? LockedDate { get; internal set; }
136 |
137 | ///
138 | /// migrated_from
139 | ///
140 | [Field("migrated_from")]
141 | public MigrationInfo MigratedFrom { get; internal set; }
142 |
143 | ///
144 | /// migrated_to
145 | ///
146 | [Field("migrated_to")]
147 | public MigrationInfo MigratedTo { get; internal set; }
148 |
149 | ///
150 | /// notice -- introduced in API version 2.1
151 | ///
152 | [Field("notice")]
153 | public Notice Notice { get; internal set; }
154 |
155 | ///
156 | /// owner
157 | ///
158 | [Field("owner")]
159 | public ShallowUser Owner { get; internal set; }
160 |
161 | ///
162 | /// protected_date
163 | ///
164 | [Field("protected_date")]
165 | public DateTime? ProtectedDate { get; internal set; }
166 |
167 | ///
168 | /// question_id
169 | ///
170 | [Field("question_id")]
171 | public int QuestionId { get; internal set; }
172 |
173 | ///
174 | /// reopen_vote_count -- introduced in API version 2.1
175 | ///
176 | [Field("reopen_vote_count")]
177 | public int ReopenVoteCount { get; internal set; }
178 |
179 | ///
180 | /// score
181 | ///
182 | [Field("score")]
183 | public int Score { get; internal set; }
184 |
185 | ///
186 | /// tags
187 | ///
188 | [Field("tags")]
189 | public string[] Tags { get; internal set; }
190 |
191 | ///
192 | /// title
193 | ///
194 | [Field("title")]
195 | public string Title { get; internal set; }
196 |
197 | ///
198 | /// up_vote_count
199 | ///
200 | [Field("up_vote_count")]
201 | public int UpVoteCount { get; internal set; }
202 |
203 | ///
204 | /// view_count
205 | ///
206 | [Field("view_count")]
207 | public int ViewCount { get; internal set; }
208 |
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/StacMan/Codegen/QuestionTimeline.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan QuestionTimeline, corresponding to Stack Exchange API v2's question_timeline type
13 | /// http://api.stackexchange.com/docs/types/question-timeline
14 | ///
15 | public partial class QuestionTimeline : StacManType
16 | {
17 | ///
18 | /// comment_id
19 | ///
20 | [Field("comment_id")]
21 | public int? CommentId { get; internal set; }
22 |
23 | ///
24 | /// creation_date
25 | ///
26 | [Field("creation_date")]
27 | public DateTime CreationDate { get; internal set; }
28 |
29 | ///
30 | /// down_vote_count
31 | ///
32 | [Field("down_vote_count")]
33 | public int? DownVoteCount { get; internal set; }
34 |
35 | ///
36 | /// owner
37 | ///
38 | [Field("owner")]
39 | public ShallowUser Owner { get; internal set; }
40 |
41 | ///
42 | /// post_id
43 | ///
44 | [Field("post_id")]
45 | public int? PostId { get; internal set; }
46 |
47 | ///
48 | /// question_id
49 | ///
50 | [Field("question_id")]
51 | public int QuestionId { get; internal set; }
52 |
53 | ///
54 | /// revision_guid
55 | ///
56 | [Field("revision_guid")]
57 | public Guid? RevisionGuid { get; internal set; }
58 |
59 | ///
60 | /// timeline_type
61 | ///
62 | [Field("timeline_type")]
63 | public QuestionTimelines.TimelineType TimelineType { get; internal set; }
64 |
65 | ///
66 | /// up_vote_count
67 | ///
68 | [Field("up_vote_count")]
69 | public int? UpVoteCount { get; internal set; }
70 |
71 | ///
72 | /// user
73 | ///
74 | [Field("user")]
75 | public ShallowUser User { get; internal set; }
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/StacMan/Codegen/RelatedSite.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan RelatedSite, corresponding to Stack Exchange API v2's related_site type
13 | /// http://api.stackexchange.com/docs/types/related-site
14 | ///
15 | public partial class RelatedSite : StacManType
16 | {
17 | ///
18 | /// api_site_parameter
19 | ///
20 | [Field("api_site_parameter")]
21 | public string ApiSiteParameter { get; internal set; }
22 |
23 | ///
24 | /// name
25 | ///
26 | [Field("name")]
27 | public string Name { get; internal set; }
28 |
29 | ///
30 | /// relation
31 | ///
32 | [Field("relation")]
33 | public string Relation { get; internal set; }
34 |
35 | ///
36 | /// site_url
37 | ///
38 | [Field("site_url")]
39 | public string SiteUrl { get; internal set; }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Reputation.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Reputation, corresponding to Stack Exchange API v2's reputation type
13 | /// http://api.stackexchange.com/docs/types/reputation
14 | ///
15 | public partial class Reputation : StacManType
16 | {
17 | ///
18 | /// link
19 | ///
20 | [Field("link")]
21 | public string Link { get; internal set; }
22 |
23 | ///
24 | /// on_date
25 | ///
26 | [Field("on_date")]
27 | public DateTime OnDate { get; internal set; }
28 |
29 | ///
30 | /// post_id
31 | ///
32 | [Field("post_id")]
33 | public int PostId { get; internal set; }
34 |
35 | ///
36 | /// post_type
37 | ///
38 | [Field("post_type")]
39 | public Posts.PostType PostType { get; internal set; }
40 |
41 | ///
42 | /// reputation_change
43 | ///
44 | [Field("reputation_change")]
45 | public int ReputationChange { get; internal set; }
46 |
47 | ///
48 | /// title
49 | ///
50 | [Field("title")]
51 | public string Title { get; internal set; }
52 |
53 | ///
54 | /// user_id
55 | ///
56 | [Field("user_id")]
57 | public int UserId { get; internal set; }
58 |
59 | ///
60 | /// vote_type
61 | ///
62 | [Field("vote_type")]
63 | public Reputations.VoteType VoteType { get; internal set; }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/StacMan/Codegen/ReputationHistory.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan ReputationHistory, corresponding to Stack Exchange API v2's reputation_history type
13 | /// http://api.stackexchange.com/docs/types/reputation-history
14 | ///
15 | public partial class ReputationHistory : StacManType
16 | {
17 | ///
18 | /// creation_date -- introduced in API version 2.1
19 | ///
20 | [Field("creation_date")]
21 | public DateTime CreationDate { get; internal set; }
22 |
23 | ///
24 | /// post_id -- introduced in API version 2.1
25 | ///
26 | [Field("post_id")]
27 | public int? PostId { get; internal set; }
28 |
29 | ///
30 | /// reputation_change -- introduced in API version 2.1
31 | ///
32 | [Field("reputation_change")]
33 | public int ReputationChange { get; internal set; }
34 |
35 | ///
36 | /// reputation_history_type -- introduced in API version 2.1
37 | ///
38 | [Field("reputation_history_type")]
39 | public ReputationHistories.ReputationHistoryType ReputationHistoryType { get; internal set; }
40 |
41 | ///
42 | /// user_id -- introduced in API version 2.1
43 | ///
44 | [Field("user_id")]
45 | public int UserId { get; internal set; }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Revision.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Revision, corresponding to Stack Exchange API v2's revision type
13 | /// http://api.stackexchange.com/docs/types/revision
14 | ///
15 | public partial class Revision : StacManType
16 | {
17 | ///
18 | /// body
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// comment
25 | ///
26 | [Field("comment")]
27 | public string Comment { get; internal set; }
28 |
29 | ///
30 | /// creation_date
31 | ///
32 | [Field("creation_date")]
33 | public DateTime CreationDate { get; internal set; }
34 |
35 | ///
36 | /// is_rollback
37 | ///
38 | [Field("is_rollback")]
39 | public bool IsRollback { get; internal set; }
40 |
41 | ///
42 | /// last_body
43 | ///
44 | [Field("last_body")]
45 | public string LastBody { get; internal set; }
46 |
47 | ///
48 | /// last_tags
49 | ///
50 | [Field("last_tags")]
51 | public string[] LastTags { get; internal set; }
52 |
53 | ///
54 | /// last_title
55 | ///
56 | [Field("last_title")]
57 | public string LastTitle { get; internal set; }
58 |
59 | ///
60 | /// post_id
61 | ///
62 | [Field("post_id")]
63 | public int PostId { get; internal set; }
64 |
65 | ///
66 | /// post_type
67 | ///
68 | [Field("post_type")]
69 | public Posts.PostType PostType { get; internal set; }
70 |
71 | ///
72 | /// revision_guid
73 | ///
74 | [Field("revision_guid")]
75 | public Guid RevisionGuid { get; internal set; }
76 |
77 | ///
78 | /// revision_number
79 | ///
80 | [Field("revision_number")]
81 | public int RevisionNumber { get; internal set; }
82 |
83 | ///
84 | /// revision_type
85 | ///
86 | [Field("revision_type")]
87 | public Revisions.RevisionType RevisionType { get; internal set; }
88 |
89 | ///
90 | /// set_community_wiki
91 | ///
92 | [Field("set_community_wiki")]
93 | public bool SetCommunityWiki { get; internal set; }
94 |
95 | ///
96 | /// tags
97 | ///
98 | [Field("tags")]
99 | public string[] Tags { get; internal set; }
100 |
101 | ///
102 | /// title
103 | ///
104 | [Field("title")]
105 | public string Title { get; internal set; }
106 |
107 | ///
108 | /// user
109 | ///
110 | [Field("user")]
111 | public ShallowUser User { get; internal set; }
112 |
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/StacMan/Codegen/ShallowUser.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan ShallowUser, corresponding to Stack Exchange API v2's shallow_user type
13 | /// http://api.stackexchange.com/docs/types/shallow-user
14 | ///
15 | public partial class ShallowUser : StacManType
16 | {
17 | ///
18 | /// accept_rate
19 | ///
20 | [Field("accept_rate")]
21 | public int? AcceptRate { get; internal set; }
22 |
23 | ///
24 | /// display_name
25 | ///
26 | [Field("display_name")]
27 | public string DisplayName { get; internal set; }
28 |
29 | ///
30 | /// link
31 | ///
32 | [Field("link")]
33 | public string Link { get; internal set; }
34 |
35 | ///
36 | /// profile_image
37 | ///
38 | [Field("profile_image")]
39 | public string ProfileImage { get; internal set; }
40 |
41 | ///
42 | /// reputation
43 | ///
44 | [Field("reputation")]
45 | public int? Reputation { get; internal set; }
46 |
47 | ///
48 | /// user_id
49 | ///
50 | [Field("user_id")]
51 | public int? UserId { get; internal set; }
52 |
53 | ///
54 | /// user_type
55 | ///
56 | [Field("user_type")]
57 | public Users.UserType UserType { get; internal set; }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Site.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Site, corresponding to Stack Exchange API v2's site type
13 | /// http://api.stackexchange.com/docs/types/site
14 | ///
15 | public partial class Site : StacManType
16 | {
17 | ///
18 | /// aliases
19 | ///
20 | [Field("aliases")]
21 | public string[] Aliases { get; internal set; }
22 |
23 | ///
24 | /// api_site_parameter
25 | ///
26 | [Field("api_site_parameter")]
27 | public string ApiSiteParameter { get; internal set; }
28 |
29 | ///
30 | /// audience
31 | ///
32 | [Field("audience")]
33 | public string Audience { get; internal set; }
34 |
35 | ///
36 | /// closed_beta_date
37 | ///
38 | [Field("closed_beta_date")]
39 | public DateTime? ClosedBetaDate { get; internal set; }
40 |
41 | ///
42 | /// favicon_url
43 | ///
44 | [Field("favicon_url")]
45 | public string FaviconUrl { get; internal set; }
46 |
47 | ///
48 | /// high_resolution_icon_url -- introduced in API version 2.1
49 | ///
50 | [Field("high_resolution_icon_url")]
51 | public string HighResolutionIconUrl { get; internal set; }
52 |
53 | ///
54 | /// icon_url
55 | ///
56 | [Field("icon_url")]
57 | public string IconUrl { get; internal set; }
58 |
59 | ///
60 | /// launch_date
61 | ///
62 | [Field("launch_date")]
63 | public DateTime LaunchDate { get; internal set; }
64 |
65 | ///
66 | /// logo_url
67 | ///
68 | [Field("logo_url")]
69 | public string LogoUrl { get; internal set; }
70 |
71 | ///
72 | /// markdown_extensions
73 | ///
74 | [Field("markdown_extensions")]
75 | public string[] MarkdownExtensions { get; internal set; }
76 |
77 | ///
78 | /// name
79 | ///
80 | [Field("name")]
81 | public string Name { get; internal set; }
82 |
83 | ///
84 | /// open_beta_date
85 | ///
86 | [Field("open_beta_date")]
87 | public DateTime? OpenBetaDate { get; internal set; }
88 |
89 | ///
90 | /// related_sites
91 | ///
92 | [Field("related_sites")]
93 | public RelatedSite[] RelatedSites { get; internal set; }
94 |
95 | ///
96 | /// site_state
97 | ///
98 | [Field("site_state")]
99 | public Sites.SiteState SiteState { get; internal set; }
100 |
101 | ///
102 | /// site_type
103 | ///
104 | [Field("site_type")]
105 | public string SiteType { get; internal set; }
106 |
107 | ///
108 | /// site_url
109 | ///
110 | [Field("site_url")]
111 | public string SiteUrl { get; internal set; }
112 |
113 | ///
114 | /// styling
115 | ///
116 | [Field("styling")]
117 | public Styling Styling { get; internal set; }
118 |
119 | ///
120 | /// twitter_account
121 | ///
122 | [Field("twitter_account")]
123 | public string TwitterAccount { get; internal set; }
124 |
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.AccessTokenMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IAccessTokenMethods
16 | {
17 | ///
18 | /// Stack Exchange API AccessTokens methods
19 | ///
20 | public IAccessTokenMethods AccessTokens
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IAccessTokenMethods.Invalidate(IEnumerable accessTokens, string filter, int? page, int? pagesize)
26 | {
27 | ValidateEnumerable(accessTokens, "accessTokens");
28 | ValidatePaging(page, pagesize);
29 |
30 | var ub = new ApiUrlBuilder(Version, String.Format("/access-tokens/{0}/invalidate", String.Join(";", accessTokens.Select(HttpUtility.UrlEncode))), useHttps: false);
31 |
32 | ub.AddParameter("filter", filter);
33 | ub.AddParameter("page", page);
34 | ub.AddParameter("pagesize", pagesize);
35 |
36 | return CreateApiTask(ub, HttpMethod.GET, "/access-tokens/{accessTokens}/invalidate");
37 | }
38 |
39 | Task> IAccessTokenMethods.Get(IEnumerable accessTokens, string filter, int? page, int? pagesize)
40 | {
41 | ValidateEnumerable(accessTokens, "accessTokens");
42 | ValidatePaging(page, pagesize);
43 |
44 | var ub = new ApiUrlBuilder(Version, String.Format("/access-tokens/{0}", String.Join(";", accessTokens.Select(HttpUtility.UrlEncode))), useHttps: false);
45 |
46 | ub.AddParameter("filter", filter);
47 | ub.AddParameter("page", page);
48 | ub.AddParameter("pagesize", pagesize);
49 |
50 | return CreateApiTask(ub, HttpMethod.GET, "/access-tokens/{accessTokens}");
51 | }
52 | }
53 |
54 | ///
55 | /// Stack Exchange API AccessTokens methods
56 | ///
57 | public interface IAccessTokenMethods
58 | {
59 | ///
60 | /// Allows an application to dispose of access_tokens when it is done with them. (API Method: "/access-tokens/{accessTokens}/invalidate")
61 | ///
62 | Task> Invalidate(IEnumerable accessTokens, string filter = null, int? page = null, int? pagesize = null);
63 |
64 | ///
65 | /// Allows an application to inspect access_tokens it has, useful for debugging. (API Method: "/access-tokens/{accessTokens}")
66 | ///
67 | Task> Get(IEnumerable accessTokens, string filter = null, int? page = null, int? pagesize = null);
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.AnswerMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IAnswerMethods
16 | {
17 | ///
18 | /// Stack Exchange API Answers methods
19 | ///
20 | public IAnswerMethods Answers
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IAnswerMethods.GetAll(string site, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Answers.Sort? sort, DateTime? mindate, DateTime? maxdate, int? min, int? max, Order? order)
26 | {
27 | ValidateString(site, "site");
28 | ValidatePaging(page, pagesize);
29 | ValidateSortMinMax(sort, mindate: mindate, maxdate: maxdate, min: min, max: max);
30 |
31 | var ub = new ApiUrlBuilder(Version, "/answers", useHttps: false);
32 |
33 | ub.AddParameter("site", site);
34 | ub.AddParameter("filter", filter);
35 | ub.AddParameter("page", page);
36 | ub.AddParameter("pagesize", pagesize);
37 | ub.AddParameter("fromdate", fromdate);
38 | ub.AddParameter("todate", todate);
39 | ub.AddParameter("sort", sort);
40 | ub.AddParameter("min", mindate);
41 | ub.AddParameter("max", maxdate);
42 | ub.AddParameter("min", min);
43 | ub.AddParameter("max", max);
44 | ub.AddParameter("order", order);
45 |
46 | return CreateApiTask(ub, HttpMethod.GET, "/answers");
47 | }
48 |
49 | Task> IAnswerMethods.GetByIds(string site, IEnumerable ids, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Answers.Sort? sort, DateTime? mindate, DateTime? maxdate, int? min, int? max, Order? order)
50 | {
51 | ValidateString(site, "site");
52 | ValidateEnumerable(ids, "ids");
53 | ValidatePaging(page, pagesize);
54 | ValidateSortMinMax(sort, mindate: mindate, maxdate: maxdate, min: min, max: max);
55 |
56 | var ub = new ApiUrlBuilder(Version, String.Format("/answers/{0}", String.Join(";", ids)), useHttps: false);
57 |
58 | ub.AddParameter("site", site);
59 | ub.AddParameter("filter", filter);
60 | ub.AddParameter("page", page);
61 | ub.AddParameter("pagesize", pagesize);
62 | ub.AddParameter("fromdate", fromdate);
63 | ub.AddParameter("todate", todate);
64 | ub.AddParameter("sort", sort);
65 | ub.AddParameter("min", mindate);
66 | ub.AddParameter("max", maxdate);
67 | ub.AddParameter("min", min);
68 | ub.AddParameter("max", max);
69 | ub.AddParameter("order", order);
70 |
71 | return CreateApiTask(ub, HttpMethod.GET, "/answers/{ids}");
72 | }
73 |
74 | Task> IAnswerMethods.GetComments(string site, IEnumerable ids, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Comments.Sort? sort, DateTime? mindate, DateTime? maxdate, int? min, int? max, Order? order)
75 | {
76 | ValidateString(site, "site");
77 | ValidateEnumerable(ids, "ids");
78 | ValidatePaging(page, pagesize);
79 | ValidateSortMinMax(sort, mindate: mindate, maxdate: maxdate, min: min, max: max);
80 |
81 | var ub = new ApiUrlBuilder(Version, String.Format("/answers/{0}/comments", String.Join(";", ids)), useHttps: false);
82 |
83 | ub.AddParameter("site", site);
84 | ub.AddParameter("filter", filter);
85 | ub.AddParameter("page", page);
86 | ub.AddParameter("pagesize", pagesize);
87 | ub.AddParameter("fromdate", fromdate);
88 | ub.AddParameter("todate", todate);
89 | ub.AddParameter("sort", sort);
90 | ub.AddParameter("min", mindate);
91 | ub.AddParameter("max", maxdate);
92 | ub.AddParameter("min", min);
93 | ub.AddParameter("max", max);
94 | ub.AddParameter("order", order);
95 |
96 | return CreateApiTask(ub, HttpMethod.GET, "/answers/{ids}/comments");
97 | }
98 | }
99 |
100 | ///
101 | /// Stack Exchange API Answers methods
102 | ///
103 | public interface IAnswerMethods
104 | {
105 | ///
106 | /// Get all answers on the site. (API Method: "/answers")
107 | ///
108 | Task> GetAll(string site, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, Answers.Sort? sort = null, DateTime? mindate = null, DateTime? maxdate = null, int? min = null, int? max = null, Order? order = null);
109 |
110 | ///
111 | /// Get answers identified by a set of ids. (API Method: "/answers/{ids}")
112 | ///
113 | Task> GetByIds(string site, IEnumerable ids, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, Answers.Sort? sort = null, DateTime? mindate = null, DateTime? maxdate = null, int? min = null, int? max = null, Order? order = null);
114 |
115 | ///
116 | /// Get comments on the answers identified by a set of ids. (API Method: "/answers/{ids}/comments")
117 | ///
118 | Task> GetComments(string site, IEnumerable ids, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, Comments.Sort? sort = null, DateTime? mindate = null, DateTime? maxdate = null, int? min = null, int? max = null, Order? order = null);
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.ApplicationMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IApplicationMethods
16 | {
17 | ///
18 | /// Stack Exchange API Applications methods
19 | ///
20 | public IApplicationMethods Applications
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IApplicationMethods.Deauthenticate(IEnumerable accessTokens, string filter, int? page, int? pagesize)
26 | {
27 | ValidateEnumerable(accessTokens, "accessTokens");
28 | ValidatePaging(page, pagesize);
29 |
30 | var ub = new ApiUrlBuilder(Version, String.Format("/apps/{0}/de-authenticate", String.Join(";", accessTokens.Select(HttpUtility.UrlEncode))), useHttps: false);
31 |
32 | ub.AddParameter("filter", filter);
33 | ub.AddParameter("page", page);
34 | ub.AddParameter("pagesize", pagesize);
35 |
36 | return CreateApiTask(ub, HttpMethod.GET, "/apps/{accessTokens}/de-authenticate");
37 | }
38 | }
39 |
40 | ///
41 | /// Stack Exchange API Applications methods
42 | ///
43 | public interface IApplicationMethods
44 | {
45 | ///
46 | /// Allows an application to de-authorize itself for a set of users. (API Method: "/apps/{accessTokens}/de-authenticate")
47 | ///
48 | Task> Deauthenticate(IEnumerable accessTokens, string filter = null, int? page = null, int? pagesize = null);
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.ErrorMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IErrorMethods
16 | {
17 | ///
18 | /// Stack Exchange API Errors methods
19 | ///
20 | public IErrorMethods Errors
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IErrorMethods.GetAll(string filter, int? page, int? pagesize)
26 | {
27 | ValidatePaging(page, pagesize);
28 |
29 | var ub = new ApiUrlBuilder(Version, "/errors", useHttps: false);
30 |
31 | ub.AddParameter("filter", filter);
32 | ub.AddParameter("page", page);
33 | ub.AddParameter("pagesize", pagesize);
34 |
35 | return CreateApiTask(ub, HttpMethod.GET, "/errors");
36 | }
37 |
38 | Task> IErrorMethods.Simulate(int id, string filter)
39 | {
40 |
41 | var ub = new ApiUrlBuilder(Version, String.Format("/errors/{0}", id), useHttps: false);
42 |
43 | ub.AddParameter("filter", filter);
44 |
45 | return CreateApiTask(ub, HttpMethod.GET, "/errors/{id}");
46 | }
47 | }
48 |
49 | ///
50 | /// Stack Exchange API Errors methods
51 | ///
52 | public interface IErrorMethods
53 | {
54 | ///
55 | /// Get descriptions of all the errors that the API could return. (API Method: "/errors")
56 | ///
57 | Task> GetAll(string filter = null, int? page = null, int? pagesize = null);
58 |
59 | ///
60 | /// Simulate an API error for testing purposes. (API Method: "/errors/{id}")
61 | ///
62 | Task> Simulate(int id, string filter = null);
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.EventMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IEventMethods
16 | {
17 | ///
18 | /// Stack Exchange API Events methods
19 | ///
20 | public IEventMethods Events
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IEventMethods.GetRecent(string site, string access_token, string filter, int? page, int? pagesize, DateTime? since)
26 | {
27 | ValidateString(site, "site");
28 | ValidateString(access_token, "access_token");
29 | ValidatePaging(page, pagesize);
30 |
31 | var ub = new ApiUrlBuilder(Version, "/events", useHttps: true);
32 |
33 | ub.AddParameter("site", site);
34 | ub.AddParameter("access_token", access_token);
35 | ub.AddParameter("filter", filter);
36 | ub.AddParameter("page", page);
37 | ub.AddParameter("pagesize", pagesize);
38 | ub.AddParameter("since", since);
39 |
40 | return CreateApiTask(ub, HttpMethod.GET, "/events");
41 | }
42 | }
43 |
44 | ///
45 | /// Stack Exchange API Events methods
46 | ///
47 | public interface IEventMethods
48 | {
49 | ///
50 | /// Get recent events that have occurred on the site. Effectively a stream of new users and content. [auth required] (API Method: "/events")
51 | ///
52 | Task> GetRecent(string site, string access_token, string filter = null, int? page = null, int? pagesize = null, DateTime? since = null);
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.FilterMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IFilterMethods
16 | {
17 | ///
18 | /// Stack Exchange API Filters methods
19 | ///
20 | public IFilterMethods Filters
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IFilterMethods.Read(IEnumerable filters, string filter)
26 | {
27 | ValidateEnumerable(filters, "filters");
28 |
29 | var ub = new ApiUrlBuilder(Version, String.Format("/filters/{0}", String.Join(";", filters.Select(HttpUtility.UrlEncode))), useHttps: false);
30 |
31 | ub.AddParameter("filter", filter);
32 |
33 | return CreateApiTask(ub, HttpMethod.GET, "/filters/{filters}");
34 | }
35 |
36 | Task> IFilterMethods.Create(string filter, IEnumerable include, IEnumerable exclude, string @base, bool? @unsafe)
37 | {
38 |
39 | var ub = new ApiUrlBuilder(Version, "/filters/create", useHttps: false);
40 |
41 | ub.AddParameter("filter", filter);
42 | ub.AddParameter("include", include);
43 | ub.AddParameter("exclude", exclude);
44 | ub.AddParameter("base", @base);
45 | ub.AddParameter("unsafe", @unsafe);
46 |
47 | return CreateApiTask(ub, HttpMethod.GET, "/filters/create");
48 | }
49 | }
50 |
51 | ///
52 | /// Stack Exchange API Filters methods
53 | ///
54 | public interface IFilterMethods
55 | {
56 | ///
57 | /// Decode a set of filters, useful for debugging purposes. (API Method: "/filters/{filters}")
58 | ///
59 | Task> Read(IEnumerable filters, string filter = null);
60 |
61 | ///
62 | /// Create a new filter. (API Method: "/filters/create")
63 | ///
64 | Task> Create(string filter = null, IEnumerable include = null, IEnumerable exclude = null, string @base = null, bool? @unsafe = null);
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.InboxMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IInboxMethods
16 | {
17 | ///
18 | /// Stack Exchange API Inbox methods
19 | ///
20 | public IInboxMethods Inbox
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IInboxMethods.Get(string access_token, string filter, int? page, int? pagesize)
26 | {
27 | ValidateString(access_token, "access_token");
28 | ValidatePaging(page, pagesize);
29 |
30 | var ub = new ApiUrlBuilder(Version, "/inbox", useHttps: true);
31 |
32 | ub.AddParameter("access_token", access_token);
33 | ub.AddParameter("filter", filter);
34 | ub.AddParameter("page", page);
35 | ub.AddParameter("pagesize", pagesize);
36 |
37 | return CreateApiTask(ub, HttpMethod.GET, "/inbox");
38 | }
39 |
40 | Task> IInboxMethods.GetUnread(string access_token, string filter, int? page, int? pagesize, DateTime? since)
41 | {
42 | ValidateString(access_token, "access_token");
43 | ValidatePaging(page, pagesize);
44 |
45 | var ub = new ApiUrlBuilder(Version, "/inbox/unread", useHttps: true);
46 |
47 | ub.AddParameter("access_token", access_token);
48 | ub.AddParameter("filter", filter);
49 | ub.AddParameter("page", page);
50 | ub.AddParameter("pagesize", pagesize);
51 | ub.AddParameter("since", since);
52 |
53 | return CreateApiTask(ub, HttpMethod.GET, "/inbox/unread");
54 | }
55 | }
56 |
57 | ///
58 | /// Stack Exchange API Inbox methods
59 | ///
60 | public interface IInboxMethods
61 | {
62 | ///
63 | /// Get a user's inbox, outside of the context of a site. [auth required] (API Method: "/inbox")
64 | ///
65 | Task> Get(string access_token, string filter = null, int? page = null, int? pagesize = null);
66 |
67 | ///
68 | /// Get the unread items in a user's inbox, outside of the context of a site. [auth required] (API Method: "/inbox/unread")
69 | ///
70 | Task> GetUnread(string access_token, string filter = null, int? page = null, int? pagesize = null, DateTime? since = null);
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.InfoMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IInfoMethods
16 | {
17 | ///
18 | /// Stack Exchange API Info methods
19 | ///
20 | public IInfoMethods Info
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IInfoMethods.Get(string site, string filter)
26 | {
27 | ValidateString(site, "site");
28 |
29 | var ub = new ApiUrlBuilder(Version, "/info", useHttps: false);
30 |
31 | ub.AddParameter("site", site);
32 | ub.AddParameter("filter", filter);
33 |
34 | return CreateApiTask(ub, HttpMethod.GET, "/info");
35 | }
36 | }
37 |
38 | ///
39 | /// Stack Exchange API Info methods
40 | ///
41 | public interface IInfoMethods
42 | {
43 | ///
44 | /// Get information about the entire site. (API Method: "/info")
45 | ///
46 | Task> Get(string site, string filter = null);
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.NotificationMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : INotificationMethods
16 | {
17 | ///
18 | /// Stack Exchange API Notifications methods
19 | ///
20 | public INotificationMethods Notifications
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> INotificationMethods.Get(string access_token, string filter, int? page, int? pagesize)
26 | {
27 | ValidateString(access_token, "access_token");
28 | ValidateMinApiVersion("2.1");
29 | ValidatePaging(page, pagesize);
30 |
31 | var ub = new ApiUrlBuilder(Version, "/notifications", useHttps: true);
32 |
33 | ub.AddParameter("access_token", access_token);
34 | ub.AddParameter("filter", filter);
35 | ub.AddParameter("page", page);
36 | ub.AddParameter("pagesize", pagesize);
37 |
38 | return CreateApiTask(ub, HttpMethod.GET, "/notifications");
39 | }
40 |
41 | Task> INotificationMethods.GetUnread(string access_token, string filter, int? page, int? pagesize)
42 | {
43 | ValidateString(access_token, "access_token");
44 | ValidateMinApiVersion("2.1");
45 | ValidatePaging(page, pagesize);
46 |
47 | var ub = new ApiUrlBuilder(Version, "/notifications/unread", useHttps: true);
48 |
49 | ub.AddParameter("access_token", access_token);
50 | ub.AddParameter("filter", filter);
51 | ub.AddParameter("page", page);
52 | ub.AddParameter("pagesize", pagesize);
53 |
54 | return CreateApiTask(ub, HttpMethod.GET, "/notifications/unread");
55 | }
56 | }
57 |
58 | ///
59 | /// Stack Exchange API Notifications methods
60 | ///
61 | public interface INotificationMethods
62 | {
63 | ///
64 | /// Get a user's notifications, outside of the context of a site. [auth required] (API Method: "/notifications") -- introduced in API version 2.1
65 | ///
66 | Task> Get(string access_token, string filter = null, int? page = null, int? pagesize = null);
67 |
68 | ///
69 | /// Get a user's unread notifications, outside of the context of a site. [auth required] (API Method: "/notifications/unread") -- introduced in API version 2.1
70 | ///
71 | Task> GetUnread(string access_token, string filter = null, int? page = null, int? pagesize = null);
72 |
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.PrivilegeMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IPrivilegeMethods
16 | {
17 | ///
18 | /// Stack Exchange API Privileges methods
19 | ///
20 | public IPrivilegeMethods Privileges
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IPrivilegeMethods.GetAll(string site, string filter, int? page, int? pagesize)
26 | {
27 | ValidateString(site, "site");
28 | ValidatePaging(page, pagesize);
29 |
30 | var ub = new ApiUrlBuilder(Version, "/privileges", useHttps: false);
31 |
32 | ub.AddParameter("site", site);
33 | ub.AddParameter("filter", filter);
34 | ub.AddParameter("page", page);
35 | ub.AddParameter("pagesize", pagesize);
36 |
37 | return CreateApiTask(ub, HttpMethod.GET, "/privileges");
38 | }
39 | }
40 |
41 | ///
42 | /// Stack Exchange API Privileges methods
43 | ///
44 | public interface IPrivilegeMethods
45 | {
46 | ///
47 | /// Get all the privileges available on the site. (API Method: "/privileges")
48 | ///
49 | Task> GetAll(string site, string filter = null, int? page = null, int? pagesize = null);
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.RevisionMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : IRevisionMethods
16 | {
17 | ///
18 | /// Stack Exchange API Revisions methods
19 | ///
20 | public IRevisionMethods Revisions
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> IRevisionMethods.GetByIds(string site, IEnumerable ids, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate)
26 | {
27 | ValidateString(site, "site");
28 | ValidateEnumerable(ids, "ids");
29 | ValidatePaging(page, pagesize);
30 |
31 | var ub = new ApiUrlBuilder(Version, String.Format("/revisions/{0}", String.Join(";", ids)), useHttps: false);
32 |
33 | ub.AddParameter("site", site);
34 | ub.AddParameter("filter", filter);
35 | ub.AddParameter("page", page);
36 | ub.AddParameter("pagesize", pagesize);
37 | ub.AddParameter("fromdate", fromdate);
38 | ub.AddParameter("todate", todate);
39 |
40 | return CreateApiTask(ub, HttpMethod.GET, "/revisions/{ids}");
41 | }
42 | }
43 |
44 | ///
45 | /// Stack Exchange API Revisions methods
46 | ///
47 | public interface IRevisionMethods
48 | {
49 | ///
50 | /// Get all revisions identified by a set of ids. (API Method: "/revisions/{ids}")
51 | ///
52 | Task> GetByIds(string site, IEnumerable ids, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null);
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.SiteMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : ISiteMethods
16 | {
17 | ///
18 | /// Stack Exchange API Sites methods
19 | ///
20 | public ISiteMethods Sites
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> ISiteMethods.GetAll(string filter, int? page, int? pagesize)
26 | {
27 | ValidatePaging(page, pagesize);
28 |
29 | var ub = new ApiUrlBuilder(Version, "/sites", useHttps: false);
30 |
31 | ub.AddParameter("filter", filter);
32 | ub.AddParameter("page", page);
33 | ub.AddParameter("pagesize", pagesize);
34 |
35 | return CreateApiTask(ub, HttpMethod.GET, "/sites");
36 | }
37 | }
38 |
39 | ///
40 | /// Stack Exchange API Sites methods
41 | ///
42 | public interface ISiteMethods
43 | {
44 | ///
45 | /// Get all the sites in the Stack Exchange network. (API Method: "/sites")
46 | ///
47 | Task> GetAll(string filter = null, int? page = null, int? pagesize = null);
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/StacMan/Codegen/StacManClient.SuggestedEditMethods.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 | using System.Web;
12 |
13 | namespace StackExchange.StacMan
14 | {
15 | public partial class StacManClient : ISuggestedEditMethods
16 | {
17 | ///
18 | /// Stack Exchange API SuggestedEdits methods
19 | ///
20 | public ISuggestedEditMethods SuggestedEdits
21 | {
22 | get { return this; }
23 | }
24 |
25 | Task> ISuggestedEditMethods.GetAll(string site, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, SuggestedEdits.Sort? sort, DateTime? mindate, DateTime? maxdate, Order? order)
26 | {
27 | ValidateString(site, "site");
28 | ValidatePaging(page, pagesize);
29 | ValidateSortMinMax(sort, mindate: mindate, maxdate: maxdate);
30 |
31 | var ub = new ApiUrlBuilder(Version, "/suggested-edits", useHttps: false);
32 |
33 | ub.AddParameter("site", site);
34 | ub.AddParameter("filter", filter);
35 | ub.AddParameter("page", page);
36 | ub.AddParameter("pagesize", pagesize);
37 | ub.AddParameter("fromdate", fromdate);
38 | ub.AddParameter("todate", todate);
39 | ub.AddParameter("sort", sort);
40 | ub.AddParameter("min", mindate);
41 | ub.AddParameter("max", maxdate);
42 | ub.AddParameter("order", order);
43 |
44 | return CreateApiTask(ub, HttpMethod.GET, "/suggested-edits");
45 | }
46 |
47 | Task> ISuggestedEditMethods.GetByIds(string site, IEnumerable ids, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, SuggestedEdits.Sort? sort, DateTime? mindate, DateTime? maxdate, Order? order)
48 | {
49 | ValidateString(site, "site");
50 | ValidateEnumerable(ids, "ids");
51 | ValidatePaging(page, pagesize);
52 | ValidateSortMinMax(sort, mindate: mindate, maxdate: maxdate);
53 |
54 | var ub = new ApiUrlBuilder(Version, String.Format("/suggested-edits/{0}", String.Join(";", ids)), useHttps: false);
55 |
56 | ub.AddParameter("site", site);
57 | ub.AddParameter("filter", filter);
58 | ub.AddParameter("page", page);
59 | ub.AddParameter("pagesize", pagesize);
60 | ub.AddParameter("fromdate", fromdate);
61 | ub.AddParameter("todate", todate);
62 | ub.AddParameter("sort", sort);
63 | ub.AddParameter("min", mindate);
64 | ub.AddParameter("max", maxdate);
65 | ub.AddParameter("order", order);
66 |
67 | return CreateApiTask(ub, HttpMethod.GET, "/suggested-edits/{ids}");
68 | }
69 | }
70 |
71 | ///
72 | /// Stack Exchange API SuggestedEdits methods
73 | ///
74 | public interface ISuggestedEditMethods
75 | {
76 | ///
77 | /// Get all the suggested edits on the site. (API Method: "/suggested-edits")
78 | ///
79 | Task> GetAll(string site, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, SuggestedEdits.Sort? sort = null, DateTime? mindate = null, DateTime? maxdate = null, Order? order = null);
80 |
81 | ///
82 | /// Get the suggested edits identified by a set of ids. (API Method: "/suggested-edits/{ids}")
83 | ///
84 | Task> GetByIds(string site, IEnumerable ids, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, SuggestedEdits.Sort? sort = null, DateTime? mindate = null, DateTime? maxdate = null, Order? order = null);
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Styling.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Styling, corresponding to Stack Exchange API v2's styling type
13 | /// http://api.stackexchange.com/docs/types/styling
14 | ///
15 | public partial class Styling : StacManType
16 | {
17 | ///
18 | /// link_color
19 | ///
20 | [Field("link_color")]
21 | public string LinkColor { get; internal set; }
22 |
23 | ///
24 | /// tag_background_color
25 | ///
26 | [Field("tag_background_color")]
27 | public string TagBackgroundColor { get; internal set; }
28 |
29 | ///
30 | /// tag_foreground_color
31 | ///
32 | [Field("tag_foreground_color")]
33 | public string TagForegroundColor { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/SuggestedEdit.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan SuggestedEdit, corresponding to Stack Exchange API v2's suggested_edit type
13 | /// http://api.stackexchange.com/docs/types/suggested-edit
14 | ///
15 | public partial class SuggestedEdit : StacManType
16 | {
17 | ///
18 | /// approval_date
19 | ///
20 | [Field("approval_date")]
21 | public DateTime? ApprovalDate { get; internal set; }
22 |
23 | ///
24 | /// body
25 | ///
26 | [Field("body")]
27 | public string Body { get; internal set; }
28 |
29 | ///
30 | /// comment
31 | ///
32 | [Field("comment")]
33 | public string Comment { get; internal set; }
34 |
35 | ///
36 | /// creation_date
37 | ///
38 | [Field("creation_date")]
39 | public DateTime CreationDate { get; internal set; }
40 |
41 | ///
42 | /// post_id
43 | ///
44 | [Field("post_id")]
45 | public int PostId { get; internal set; }
46 |
47 | ///
48 | /// post_type
49 | ///
50 | [Field("post_type")]
51 | public Posts.PostType PostType { get; internal set; }
52 |
53 | ///
54 | /// proposing_user
55 | ///
56 | [Field("proposing_user")]
57 | public ShallowUser ProposingUser { get; internal set; }
58 |
59 | ///
60 | /// rejection_date
61 | ///
62 | [Field("rejection_date")]
63 | public DateTime? RejectionDate { get; internal set; }
64 |
65 | ///
66 | /// suggested_edit_id
67 | ///
68 | [Field("suggested_edit_id")]
69 | public int SuggestedEditId { get; internal set; }
70 |
71 | ///
72 | /// tags
73 | ///
74 | [Field("tags")]
75 | public string[] Tags { get; internal set; }
76 |
77 | ///
78 | /// title
79 | ///
80 | [Field("title")]
81 | public string Title { get; internal set; }
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Tag.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Tag, corresponding to Stack Exchange API v2's tag type
13 | /// http://api.stackexchange.com/docs/types/tag
14 | ///
15 | public partial class Tag : StacManType
16 | {
17 | ///
18 | /// count
19 | ///
20 | [Field("count")]
21 | public int Count { get; internal set; }
22 |
23 | ///
24 | /// has_synonyms
25 | ///
26 | [Field("has_synonyms")]
27 | public bool HasSynonyms { get; internal set; }
28 |
29 | ///
30 | /// is_moderator_only
31 | ///
32 | [Field("is_moderator_only")]
33 | public bool IsModeratorOnly { get; internal set; }
34 |
35 | ///
36 | /// is_required
37 | ///
38 | [Field("is_required")]
39 | public bool IsRequired { get; internal set; }
40 |
41 | ///
42 | /// last_activity_date
43 | ///
44 | [Field("last_activity_date")]
45 | public DateTime? LastActivityDate { get; internal set; }
46 |
47 | ///
48 | /// name
49 | ///
50 | [Field("name")]
51 | public string Name { get; internal set; }
52 |
53 | ///
54 | /// user_id
55 | ///
56 | [Field("user_id")]
57 | public int? UserId { get; internal set; }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/StacMan/Codegen/TagScore.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan TagScore, corresponding to Stack Exchange API v2's tag_score type
13 | /// http://api.stackexchange.com/docs/types/tag-score
14 | ///
15 | public partial class TagScore : StacManType
16 | {
17 | ///
18 | /// post_count
19 | ///
20 | [Field("post_count")]
21 | public int PostCount { get; internal set; }
22 |
23 | ///
24 | /// score
25 | ///
26 | [Field("score")]
27 | public int Score { get; internal set; }
28 |
29 | ///
30 | /// user
31 | ///
32 | [Field("user")]
33 | public ShallowUser User { get; internal set; }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/StacMan/Codegen/TagSynonym.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan TagSynonym, corresponding to Stack Exchange API v2's tag_synonym type
13 | /// http://api.stackexchange.com/docs/types/tag-synonym
14 | ///
15 | public partial class TagSynonym : StacManType
16 | {
17 | ///
18 | /// applied_count
19 | ///
20 | [Field("applied_count")]
21 | public int AppliedCount { get; internal set; }
22 |
23 | ///
24 | /// creation_date
25 | ///
26 | [Field("creation_date")]
27 | public DateTime CreationDate { get; internal set; }
28 |
29 | ///
30 | /// from_tag
31 | ///
32 | [Field("from_tag")]
33 | public string FromTag { get; internal set; }
34 |
35 | ///
36 | /// last_applied_date
37 | ///
38 | [Field("last_applied_date")]
39 | public DateTime? LastAppliedDate { get; internal set; }
40 |
41 | ///
42 | /// to_tag
43 | ///
44 | [Field("to_tag")]
45 | public string ToTag { get; internal set; }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan/Codegen/TagWiki.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan TagWiki, corresponding to Stack Exchange API v2's tag_wiki type
13 | /// http://api.stackexchange.com/docs/types/tag-wiki
14 | ///
15 | public partial class TagWiki : StacManType
16 | {
17 | ///
18 | /// body
19 | ///
20 | [Field("body")]
21 | public string Body { get; internal set; }
22 |
23 | ///
24 | /// body_last_edit_date
25 | ///
26 | [Field("body_last_edit_date")]
27 | public DateTime? BodyLastEditDate { get; internal set; }
28 |
29 | ///
30 | /// excerpt
31 | ///
32 | [Field("excerpt")]
33 | public string Excerpt { get; internal set; }
34 |
35 | ///
36 | /// excerpt_last_edit_date
37 | ///
38 | [Field("excerpt_last_edit_date")]
39 | public DateTime? ExcerptLastEditDate { get; internal set; }
40 |
41 | ///
42 | /// last_body_editor
43 | ///
44 | [Field("last_body_editor")]
45 | public ShallowUser LastBodyEditor { get; internal set; }
46 |
47 | ///
48 | /// last_excerpt_editor
49 | ///
50 | [Field("last_excerpt_editor")]
51 | public ShallowUser LastExcerptEditor { get; internal set; }
52 |
53 | ///
54 | /// tag_name
55 | ///
56 | [Field("tag_name")]
57 | public string TagName { get; internal set; }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/StacMan/Codegen/TopTag.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan TopTag, corresponding to Stack Exchange API v2's top_tag type
13 | /// http://api.stackexchange.com/docs/types/top-tag
14 | ///
15 | public partial class TopTag : StacManType
16 | {
17 | ///
18 | /// answer_count
19 | ///
20 | [Field("answer_count")]
21 | public int AnswerCount { get; internal set; }
22 |
23 | ///
24 | /// answer_score
25 | ///
26 | [Field("answer_score")]
27 | public int AnswerScore { get; internal set; }
28 |
29 | ///
30 | /// question_count
31 | ///
32 | [Field("question_count")]
33 | public int QuestionCount { get; internal set; }
34 |
35 | ///
36 | /// question_score
37 | ///
38 | [Field("question_score")]
39 | public int QuestionScore { get; internal set; }
40 |
41 | ///
42 | /// tag_name
43 | ///
44 | [Field("tag_name")]
45 | public string TagName { get; internal set; }
46 |
47 | ///
48 | /// user_id -- introduced in API version 2.1
49 | ///
50 | [Field("user_id")]
51 | public int UserId { get; internal set; }
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Types.ignore:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Types.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="true" hostspecific="true" language="C#" #>
2 | <#@ include file="Manager.ttinclude" #>
3 | <#@ assembly name="System.Web.Extensions" #>
4 | <#@ output extension=".ignore" #>
5 | <#@ import namespace="System.IO" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Text.RegularExpressions" #>
8 | <#@ import namespace="System.Web.Script.Serialization" #>
9 | <# // To debug, uncomment the next two lines
10 | // System.Diagnostics.Debugger.Launch();
11 | // System.Diagnostics.Debugger.Break();
12 | #>
13 | <#
14 | var manager = Manager.Create(Host, GenerationEnvironment);
15 | manager.StartHeader();
16 | #>
17 | //
18 | // This file was generated by a T4 template.
19 | // Don't change it directly as your change would get overwritten. Instead, make changes
20 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
21 | //
22 | <#
23 | manager.EndBlock();
24 |
25 | var typesJson = File.ReadAllText(this.Host.ResolvePath("Types.json"));
26 | var serializer = new JavaScriptSerializer();
27 | var typesObj = serializer.Deserialize>>(typesJson);
28 |
29 | foreach (var typeName in typesObj.Keys)
30 | {
31 | var className = (typeName == "" ? "Wrapper" : Prettify(typeName));
32 | manager.StartNewFile((typeName == "" ? "Wrapper" : Prettify(typeName)) + ".cs");
33 | #>
34 |
35 | using System;
36 |
37 | namespace StackExchange.StacMan
38 | {
39 | ///
40 | /// StacMan <#= (typeName == "" ? "Wrapper" : className) #>, corresponding to Stack Exchange API v2's <#= (typeName == "" ? "common wrapper" : typeName) #> type
41 | /// http://api.stackexchange.com/docs/<#= (typeName == "" ? "wrapper" : "types/" + typeName.Replace("_", "-")) #>
42 | ///
43 | public partial class <#= className #> : StacManType
44 | {
45 | <#
46 | var fieldsObj = typesObj[typeName];
47 |
48 | foreach (var field in fieldsObj)
49 | {
50 | var fieldName = field.Key;
51 | var fieldMinApiVersion = "2.0";
52 |
53 | var fieldVersionMatch = VersionRegex.Match(fieldName);
54 | if (fieldVersionMatch.Success)
55 | {
56 | fieldName = VersionRegex.Replace(fieldName, "");
57 | fieldMinApiVersion = fieldVersionMatch.Groups["version"].Value;
58 | }
59 |
60 | var propertyName = Prettify(fieldName);
61 |
62 | // member names cannot be the same as their enclosing type (this only affects "filter")
63 | if (propertyName == className)
64 | propertyName += "Name";
65 |
66 | var propertyTypeName = field.Value;
67 | #>
68 | ///
69 | /// <#= fieldName #><#= fieldMinApiVersion != "2.0" ? String.Format(" -- introduced in API version {0}", fieldMinApiVersion) : "" #>
70 | ///
71 | [Field("<#= fieldName #>")]
72 | public <#= propertyTypeName #> <#= propertyName #> { get; internal set; }
73 |
74 | <#
75 | }
76 | #>
77 | }
78 | }
79 | <#
80 | manager.EndBlock();
81 | }
82 | manager.Process(true);
83 | #>
84 |
85 | <#+
86 | static Regex VersionRegex = new Regex("\\((?.*)\\)$", RegexOptions.Compiled);
87 |
88 | // convert "foo_bar" to "FooBar"
89 | string Prettify(string name)
90 | {
91 | var sb = new StringBuilder();
92 | bool capitalize = true;
93 |
94 | foreach (var c in name)
95 | {
96 | if (c == '_')
97 | {
98 | capitalize = true;
99 | continue;
100 | }
101 |
102 | if (capitalize)
103 | {
104 | sb.Append(char.ToUpper(c));
105 | capitalize = false;
106 | }
107 | else
108 | {
109 | sb.Append(c);
110 | }
111 | }
112 |
113 | return sb.ToString();
114 | }
115 | #>
--------------------------------------------------------------------------------
/StacMan/Codegen/User.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan User, corresponding to Stack Exchange API v2's user type
13 | /// http://api.stackexchange.com/docs/types/user
14 | ///
15 | public partial class User : StacManType
16 | {
17 | ///
18 | /// about_me
19 | ///
20 | [Field("about_me")]
21 | public string AboutMe { get; internal set; }
22 |
23 | ///
24 | /// accept_rate
25 | ///
26 | [Field("accept_rate")]
27 | public int? AcceptRate { get; internal set; }
28 |
29 | ///
30 | /// account_id
31 | ///
32 | [Field("account_id")]
33 | public int AccountId { get; internal set; }
34 |
35 | ///
36 | /// age
37 | ///
38 | [Field("age")]
39 | public int? Age { get; internal set; }
40 |
41 | ///
42 | /// answer_count
43 | ///
44 | [Field("answer_count")]
45 | public int AnswerCount { get; internal set; }
46 |
47 | ///
48 | /// badge_counts
49 | ///
50 | [Field("badge_counts")]
51 | public BadgeCount BadgeCounts { get; internal set; }
52 |
53 | ///
54 | /// creation_date
55 | ///
56 | [Field("creation_date")]
57 | public DateTime CreationDate { get; internal set; }
58 |
59 | ///
60 | /// display_name
61 | ///
62 | [Field("display_name")]
63 | public string DisplayName { get; internal set; }
64 |
65 | ///
66 | /// down_vote_count
67 | ///
68 | [Field("down_vote_count")]
69 | public int DownVoteCount { get; internal set; }
70 |
71 | ///
72 | /// is_employee
73 | ///
74 | [Field("is_employee")]
75 | public bool IsEmployee { get; internal set; }
76 |
77 | ///
78 | /// last_access_date
79 | ///
80 | [Field("last_access_date")]
81 | public DateTime LastAccessDate { get; internal set; }
82 |
83 | ///
84 | /// last_modified_date
85 | ///
86 | [Field("last_modified_date")]
87 | public DateTime? LastModifiedDate { get; internal set; }
88 |
89 | ///
90 | /// link
91 | ///
92 | [Field("link")]
93 | public string Link { get; internal set; }
94 |
95 | ///
96 | /// location
97 | ///
98 | [Field("location")]
99 | public string Location { get; internal set; }
100 |
101 | ///
102 | /// profile_image
103 | ///
104 | [Field("profile_image")]
105 | public string ProfileImage { get; internal set; }
106 |
107 | ///
108 | /// question_count
109 | ///
110 | [Field("question_count")]
111 | public int QuestionCount { get; internal set; }
112 |
113 | ///
114 | /// reputation
115 | ///
116 | [Field("reputation")]
117 | public int Reputation { get; internal set; }
118 |
119 | ///
120 | /// reputation_change_day
121 | ///
122 | [Field("reputation_change_day")]
123 | public int ReputationChangeDay { get; internal set; }
124 |
125 | ///
126 | /// reputation_change_month
127 | ///
128 | [Field("reputation_change_month")]
129 | public int ReputationChangeMonth { get; internal set; }
130 |
131 | ///
132 | /// reputation_change_quarter
133 | ///
134 | [Field("reputation_change_quarter")]
135 | public int ReputationChangeQuarter { get; internal set; }
136 |
137 | ///
138 | /// reputation_change_week
139 | ///
140 | [Field("reputation_change_week")]
141 | public int ReputationChangeWeek { get; internal set; }
142 |
143 | ///
144 | /// reputation_change_year
145 | ///
146 | [Field("reputation_change_year")]
147 | public int ReputationChangeYear { get; internal set; }
148 |
149 | ///
150 | /// timed_penalty_date
151 | ///
152 | [Field("timed_penalty_date")]
153 | public DateTime? TimedPenaltyDate { get; internal set; }
154 |
155 | ///
156 | /// up_vote_count
157 | ///
158 | [Field("up_vote_count")]
159 | public int UpVoteCount { get; internal set; }
160 |
161 | ///
162 | /// user_id
163 | ///
164 | [Field("user_id")]
165 | public int UserId { get; internal set; }
166 |
167 | ///
168 | /// user_type
169 | ///
170 | [Field("user_type")]
171 | public Users.UserType UserType { get; internal set; }
172 |
173 | ///
174 | /// view_count
175 | ///
176 | [Field("view_count")]
177 | public int ViewCount { get; internal set; }
178 |
179 | ///
180 | /// website_url
181 | ///
182 | [Field("website_url")]
183 | public string WebsiteUrl { get; internal set; }
184 |
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/StacMan/Codegen/UserTimeline.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan UserTimeline, corresponding to Stack Exchange API v2's user_timeline type
13 | /// http://api.stackexchange.com/docs/types/user-timeline
14 | ///
15 | public partial class UserTimeline : StacManType
16 | {
17 | ///
18 | /// badge_id
19 | ///
20 | [Field("badge_id")]
21 | public int? BadgeId { get; internal set; }
22 |
23 | ///
24 | /// comment_id
25 | ///
26 | [Field("comment_id")]
27 | public int? CommentId { get; internal set; }
28 |
29 | ///
30 | /// creation_date
31 | ///
32 | [Field("creation_date")]
33 | public DateTime CreationDate { get; internal set; }
34 |
35 | ///
36 | /// detail
37 | ///
38 | [Field("detail")]
39 | public string Detail { get; internal set; }
40 |
41 | ///
42 | /// link
43 | ///
44 | [Field("link")]
45 | public string Link { get; internal set; }
46 |
47 | ///
48 | /// post_id
49 | ///
50 | [Field("post_id")]
51 | public int? PostId { get; internal set; }
52 |
53 | ///
54 | /// post_type
55 | ///
56 | [Field("post_type")]
57 | public Posts.PostType PostType { get; internal set; }
58 |
59 | ///
60 | /// suggested_edit_id
61 | ///
62 | [Field("suggested_edit_id")]
63 | public int? SuggestedEditId { get; internal set; }
64 |
65 | ///
66 | /// timeline_type
67 | ///
68 | [Field("timeline_type")]
69 | public UserTimelines.TimelineType TimelineType { get; internal set; }
70 |
71 | ///
72 | /// title
73 | ///
74 | [Field("title")]
75 | public string Title { get; internal set; }
76 |
77 | ///
78 | /// user_id
79 | ///
80 | [Field("user_id")]
81 | public int UserId { get; internal set; }
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/StacMan/Codegen/Wrapper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan Wrapper, corresponding to Stack Exchange API v2's common wrapper type
13 | /// http://api.stackexchange.com/docs/wrapper
14 | ///
15 | public partial class Wrapper : StacManType
16 | {
17 | ///
18 | /// backoff
19 | ///
20 | [Field("backoff")]
21 | public int? Backoff { get; internal set; }
22 |
23 | ///
24 | /// error_id
25 | ///
26 | [Field("error_id")]
27 | public int? ErrorId { get; internal set; }
28 |
29 | ///
30 | /// error_message
31 | ///
32 | [Field("error_message")]
33 | public string ErrorMessage { get; internal set; }
34 |
35 | ///
36 | /// error_name
37 | ///
38 | [Field("error_name")]
39 | public string ErrorName { get; internal set; }
40 |
41 | ///
42 | /// has_more
43 | ///
44 | [Field("has_more")]
45 | public bool HasMore { get; internal set; }
46 |
47 | ///
48 | /// items
49 | ///
50 | [Field("items")]
51 | public T[] Items { get; internal set; }
52 |
53 | ///
54 | /// page
55 | ///
56 | [Field("page")]
57 | public int Page { get; internal set; }
58 |
59 | ///
60 | /// page_size
61 | ///
62 | [Field("page_size")]
63 | public int PageSize { get; internal set; }
64 |
65 | ///
66 | /// quota_max
67 | ///
68 | [Field("quota_max")]
69 | public int QuotaMax { get; internal set; }
70 |
71 | ///
72 | /// quota_remaining
73 | ///
74 | [Field("quota_remaining")]
75 | public int QuotaRemaining { get; internal set; }
76 |
77 | ///
78 | /// total
79 | ///
80 | [Field("total")]
81 | public int Total { get; internal set; }
82 |
83 | ///
84 | /// type
85 | ///
86 | [Field("type")]
87 | public string Type { get; internal set; }
88 |
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/StacMan/Codegen/WritePermission.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by a T4 template.
3 | // Don't change it directly as your change would get overwritten. Instead, make changes
4 | // to the .tt file (i.e. the T4 template) and save it to regenerate this file.
5 | //
6 |
7 | using System;
8 |
9 | namespace StackExchange.StacMan
10 | {
11 | ///
12 | /// StacMan WritePermission, corresponding to Stack Exchange API v2's write_permission type
13 | /// http://api.stackexchange.com/docs/types/write-permission
14 | ///
15 | public partial class WritePermission : StacManType
16 | {
17 | ///
18 | /// can_add -- introduced in API version 2.1
19 | ///
20 | [Field("can_add")]
21 | public bool CanAdd { get; internal set; }
22 |
23 | ///
24 | /// can_delete -- introduced in API version 2.1
25 | ///
26 | [Field("can_delete")]
27 | public bool CanDelete { get; internal set; }
28 |
29 | ///
30 | /// can_edit -- introduced in API version 2.1
31 | ///
32 | [Field("can_edit")]
33 | public bool CanEdit { get; internal set; }
34 |
35 | ///
36 | /// max_daily_actions -- introduced in API version 2.1
37 | ///
38 | [Field("max_daily_actions")]
39 | public int MaxDailyActions { get; internal set; }
40 |
41 | ///
42 | /// min_seconds_between_actions -- introduced in API version 2.1
43 | ///
44 | [Field("min_seconds_between_actions")]
45 | public int MinSecondsBetweenActions { get; internal set; }
46 |
47 | ///
48 | /// object_type -- introduced in API version 2.1
49 | ///
50 | [Field("object_type")]
51 | public string ObjectType { get; internal set; }
52 |
53 | ///
54 | /// user_id -- introduced in API version 2.1
55 | ///
56 | [Field("user_id")]
57 | public int UserId { get; internal set; }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/StacMan/Comments/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Comments
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// creation_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Creation,
13 |
14 | ///
15 | /// score
16 | ///
17 | [Sort(SortType.Integer)]
18 | Votes
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/StacMan/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StackExchange.StacMan
4 | {
5 | internal static class DateTimeExtensions
6 | {
7 | private static readonly DateTime UnixEpochDateTimeUtc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
8 |
9 | public static DateTime ToDateTime(this long secondsSince1970)
10 | {
11 | return UnixEpochDateTimeUtc.AddSeconds(secondsSince1970);
12 | }
13 |
14 | public static long ToUnixTime(this DateTime dt)
15 | {
16 | return (long)(dt - UnixEpochDateTimeUtc).TotalSeconds;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/StacMan/Events/EventType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Events
2 | {
3 | ///
4 | /// event_type
5 | ///
6 | public enum EventType
7 | {
8 | ///
9 | /// question_posted
10 | ///
11 | QuestionPosted,
12 |
13 | ///
14 | /// answer_posted
15 | ///
16 | AnswerPosted,
17 |
18 | ///
19 | /// comment_posted
20 | ///
21 | CommentPosted,
22 |
23 | ///
24 | /// post_edited
25 | ///
26 | PostEdited,
27 |
28 | ///
29 | /// user_created
30 | ///
31 | UserCreated
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/StacMan/Exceptions/StackExchangeApiException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StackExchange.StacMan.Exceptions
4 | {
5 | ///
6 | /// An error encountered during a Stack Exchange API v2 method call.
7 | /// http://api.stackexchange.com/docs/error-handling
8 | ///
9 | [Serializable]
10 | public class StackExchangeApiException : Exception
11 | {
12 | ///
13 | /// Create a new StackExchangeApiException
14 | ///
15 | public StackExchangeApiException(int errorId, string errorName, string errorMessage)
16 | : base(String.Format("{0} - {1}: {2}", errorName, errorId, errorMessage))
17 | {
18 | ErrorId = errorId;
19 | ErrorName = errorName;
20 | ErrorMessage = errorMessage;
21 | }
22 |
23 | ///
24 | /// error_id
25 | ///
26 | public readonly int ErrorId;
27 |
28 | ///
29 | /// error_name
30 | ///
31 | public readonly string ErrorName;
32 |
33 | ///
34 | /// error_message
35 | ///
36 | public readonly string ErrorMessage;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/StacMan/FieldAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace StackExchange.StacMan
4 | {
5 | [AttributeUsage(AttributeTargets.Property)]
6 | internal class FieldAttribute : Attribute
7 | {
8 | public FieldAttribute(string fieldName)
9 | {
10 | FieldName = fieldName;
11 | }
12 |
13 | public readonly string FieldName;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/StacMan/InboxItems/ItemType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.InboxItems
2 | {
3 | ///
4 | /// item_type
5 | ///
6 | public enum ItemType
7 | {
8 | ///
9 | /// comment
10 | ///
11 | Comment,
12 |
13 | ///
14 | /// chat_message
15 | ///
16 | ChatMessage,
17 |
18 | ///
19 | /// new_answer
20 | ///
21 | NewAnswer,
22 |
23 | ///
24 | /// careers_message
25 | ///
26 | CareersMessage,
27 |
28 | ///
29 | /// careers_invitations
30 | ///
31 | CareersInvitations,
32 |
33 | ///
34 | /// meta_question
35 | ///
36 | MetaQuestion,
37 |
38 | ///
39 | /// post_notice
40 | ///
41 | PostNotice,
42 |
43 | ///
44 | /// moderator_message
45 | ///
46 | ModeratorMessage
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan/Notifications/NotificationType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Notifications
2 | {
3 | ///
4 | /// notification_type
5 | ///
6 | public enum NotificationType
7 | {
8 | ///
9 | /// generic
10 | ///
11 | Generic,
12 |
13 | ///
14 | /// profile_activity
15 | ///
16 | ProfileActivity,
17 |
18 | ///
19 | /// bounty_expired
20 | ///
21 | BountyExpired,
22 |
23 | ///
24 | /// bounty_expires_in_one_day
25 | ///
26 | BountyExpiresInOneDay,
27 |
28 | ///
29 | /// bounty_expires_in_three_days
30 | ///
31 | BountyExpiresInThreeDays,
32 |
33 | ///
34 | /// badge_earned
35 | ///
36 | BadgeEarned,
37 |
38 | ///
39 | /// reputation_bonus
40 | ///
41 | ReputationBonus,
42 |
43 | ///
44 | /// accounts_associated
45 | ///
46 | AccountsAssociated,
47 |
48 | ///
49 | /// new privilege
50 | ///
51 | NewPrivilege,
52 |
53 | ///
54 | /// post migrated
55 | ///
56 | PostMigrated,
57 |
58 | ///
59 | /// moderator_message
60 | ///
61 | ModeratorMessage,
62 |
63 | ///
64 | /// registration_reminder
65 | ///
66 | RegistrationReminder,
67 |
68 | ///
69 | /// edit_suggested
70 | ///
71 | EditSuggested,
72 |
73 | ///
74 | /// substantive_edit
75 | ///
76 | SubstantiveEdit
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/StacMan/Order.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan
2 | {
3 | ///
4 | /// order
5 | ///
6 | public enum Order
7 | {
8 | ///
9 | /// Ascending
10 | ///
11 | Asc,
12 |
13 | ///
14 | /// Descending
15 | ///
16 | Desc
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/StacMan/Posts/PostType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Posts
2 | {
3 | ///
4 | /// post_type
5 | ///
6 | public enum PostType
7 | {
8 | ///
9 | /// question
10 | ///
11 | Question,
12 |
13 | ///
14 | /// answer
15 | ///
16 | Answer
17 | }
18 | }
--------------------------------------------------------------------------------
/StacMan/Posts/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Posts
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// score
22 | ///
23 | [Sort(SortType.Integer)]
24 | Votes
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("StacMan.Tests")]
--------------------------------------------------------------------------------
/StacMan/QuestionTimelines/TimelineType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.QuestionTimelines
2 | {
3 | ///
4 | /// timeline_type
5 | ///
6 | public enum TimelineType
7 | {
8 | ///
9 | /// question
10 | ///
11 | Question,
12 |
13 | ///
14 | /// answer
15 | ///
16 | Answer,
17 |
18 | ///
19 | /// comment
20 | ///
21 | Comment,
22 |
23 | ///
24 | /// unaccepted_answer
25 | ///
26 | UnacceptedAnswer,
27 |
28 | ///
29 | /// accepted_answer
30 | ///
31 | AcceptedAnswer,
32 |
33 | ///
34 | /// vote_aggregate
35 | ///
36 | VoteAggregate,
37 |
38 | ///
39 | /// revision
40 | ///
41 | Revision,
42 |
43 | ///
44 | /// post_state_changed
45 | ///
46 | PostStateChanged
47 | }
48 | }
--------------------------------------------------------------------------------
/StacMan/Questions/AllSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Questions
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum AllSort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// score
16 | ///
17 | [Sort(SortType.Integer)]
18 | Votes,
19 |
20 | ///
21 | /// creation_date
22 | ///
23 | [Sort(SortType.DateTime)]
24 | Creation,
25 |
26 | ///
27 | /// by the formula ordering the hot tab
28 | ///
29 | Hot,
30 |
31 | ///
32 | /// by the formula ordering the week tab
33 | ///
34 | Week,
35 |
36 | ///
37 | /// by the formula ordering the month tab
38 | ///
39 | Month
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/StacMan/Questions/FavoriteSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Questions
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum FavoriteSort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// score
22 | ///
23 | [Sort(SortType.Integer)]
24 | Votes,
25 |
26 | ///
27 | /// when the user favorited the question
28 | ///
29 | [Sort(SortType.DateTime)]
30 | Added
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/StacMan/Questions/RelatedSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Questions
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum RelatedSort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// score
22 | ///
23 | [Sort(SortType.Integer)]
24 | Votes,
25 |
26 | ///
27 | /// a priority sort by site applies, subject to change at any time
28 | ///
29 | Rank
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/StacMan/Questions/SearchSort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Questions
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum SearchSort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// score
22 | ///
23 | [Sort(SortType.Integer)]
24 | Votes,
25 |
26 | ///
27 | /// matches the relevance tab on the site itself
28 | ///
29 | Relevance
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/StacMan/Questions/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Questions
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// last_activity_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Activity,
13 |
14 | ///
15 | /// score
16 | ///
17 | [Sort(SortType.Integer)]
18 | Votes,
19 |
20 | ///
21 | /// creation_date
22 | ///
23 | [Sort(SortType.DateTime)]
24 | Creation
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/ReflectionCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace StackExchange.StacMan
7 | {
8 | internal static class ReflectionCache
9 | {
10 | public static readonly MethodInfo StacManClientParseApiResponse = typeof(StacManClient).GetMethod("ParseApiResponse", BindingFlags.NonPublic | BindingFlags.Instance);
11 |
12 | public static class ApiFieldsByName where T : StacManType
13 | {
14 | static ApiFieldsByName()
15 | {
16 | Value = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance)
17 | .Where(pi => pi.GetCustomAttributes(typeof(FieldAttribute), false).Length == 1)
18 | .ToDictionary(
19 | pi => ((FieldAttribute)pi.GetCustomAttributes(typeof(FieldAttribute), false)[0]).FieldName,
20 | pi => pi);
21 | }
22 |
23 | public static readonly IDictionary Value;
24 | }
25 |
26 | public static class SortsBySortType where TSort : struct // proxy for "where TSort: enum"
27 | {
28 | static SortsBySortType()
29 | {
30 | Value = typeof(TSort).GetFields()
31 | .Where(fi => fi.GetCustomAttributes(typeof(SortAttribute), false).Length == 1)
32 | .GroupBy(fi => ((SortAttribute)fi.GetCustomAttributes(typeof(SortAttribute), false)[0]).SortType)
33 | .ToDictionary(
34 | grp => grp.Key,
35 | grp => grp.Select(fi => (TSort)fi.GetValue(null)).ToList());
36 | }
37 |
38 | public static readonly IDictionary> Value;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/StacMan/ReputationHistories/ReputationHistoryType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.ReputationHistories
2 | {
3 | ///
4 | /// reputation_history_type
5 | ///
6 | public enum ReputationHistoryType
7 | {
8 | ///
9 | /// asker_accepts_answer
10 | ///
11 | AskerAcceptsAnswer,
12 |
13 | ///
14 | /// askwer_unaccept_answer
15 | ///
16 | AskerUnacceptAnswer,
17 |
18 | ///
19 | /// answer_accepted
20 | ///
21 | AnswerAccepted,
22 |
23 | ///
24 | /// answer_unaccepted
25 | ///
26 | AnswerUnaccepted,
27 |
28 | ///
29 | /// voter_downvotes
30 | ///
31 | VoterDownvotes,
32 |
33 | ///
34 | /// voter_undownvotes
35 | ///
36 | VoterUndownvotes,
37 |
38 | ///
39 | /// post_downvoted
40 | ///
41 | PostDownvoted,
42 |
43 | ///
44 | /// post_undownvoted
45 | ///
46 | PostUndownvoted,
47 |
48 | ///
49 | /// post_upvoted
50 | ///
51 | PostUpvoted,
52 |
53 | ///
54 | /// post_unupvoted
55 | ///
56 | PostUnupvoted,
57 |
58 | ///
59 | /// suggested_edit_approval_received
60 | ///
61 | SuggestedEditApprovalReceived,
62 |
63 | ///
64 | /// post_flagged_as_spam
65 | ///
66 | PostFlaggedAsSpam,
67 |
68 | ///
69 | /// post_flagged_as_offensive
70 | ///
71 | PostFlaggedAsOffensive,
72 |
73 | ///
74 | /// bounty_given
75 | ///
76 | BountyGiven,
77 |
78 | ///
79 | /// bounty_earned
80 | ///
81 | BountyEarned,
82 |
83 | ///
84 | /// bounty_cancelled
85 | ///
86 | BountyCancelled,
87 |
88 | ///
89 | /// post_deleted
90 | ///
91 | PostDeleted,
92 |
93 | ///
94 | /// post_undeleted
95 | ///
96 | PostUndeleted,
97 |
98 | ///
99 | /// association_bonus
100 | ///
101 | AssociationBonus,
102 |
103 | ///
104 | /// arbitrary_reputation_change
105 | ///
106 | ArbitraryReputationChange,
107 |
108 | ///
109 | /// vote_fraud_reversal
110 | ///
111 | VoteFraudReversal,
112 |
113 | ///
114 | /// post_migrated
115 | ///
116 | PostMigrated,
117 |
118 | ///
119 | /// user_deleted
120 | ///
121 | UserDeleted
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/StacMan/Reputations/VoteType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Reputations
2 | {
3 | ///
4 | /// vote_type
5 | ///
6 | public enum VoteType
7 | {
8 | ///
9 | /// accepts
10 | ///
11 | Accepts,
12 |
13 | ///
14 | /// up_votes
15 | ///
16 | UpVotes,
17 |
18 | ///
19 | /// down_votes
20 | ///
21 | DownVotes,
22 |
23 | ///
24 | /// bounties_offered
25 | ///
26 | BountiesOffered,
27 |
28 | ///
29 | /// bounties_won
30 | ///
31 | BountiesWon,
32 |
33 | ///
34 | /// spam
35 | ///
36 | Spam,
37 |
38 | ///
39 | /// suggested_edits
40 | ///
41 | SuggestedEdits
42 | }
43 | }
--------------------------------------------------------------------------------
/StacMan/Revisions/RevisionType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Revisions
2 | {
3 | ///
4 | /// revision_type
5 | ///
6 | public enum RevisionType
7 | {
8 | ///
9 | /// single_user
10 | ///
11 | SingleUser,
12 |
13 | ///
14 | /// vote_based
15 | ///
16 | VoteBased
17 | }
18 | }
--------------------------------------------------------------------------------
/StacMan/Sites/SiteState.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Sites
2 | {
3 | ///
4 | /// site_state
5 | ///
6 | public enum SiteState
7 | {
8 | ///
9 | /// normal
10 | ///
11 | Normal,
12 |
13 | ///
14 | /// closed_beta
15 | ///
16 | ClosedBeta,
17 |
18 | ///
19 | /// open_beta
20 | ///
21 | OpenBeta,
22 |
23 | ///
24 | /// linked_meta
25 | ///
26 | LinkedMeta
27 | }
28 | }
--------------------------------------------------------------------------------
/StacMan/SortAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace StackExchange.StacMan
7 | {
8 | internal enum SortType
9 | {
10 | DateTime,
11 | Integer,
12 | String,
13 | BadgeRank,
14 | BadgeType
15 | }
16 |
17 | [AttributeUsage(AttributeTargets.Field)]
18 | internal class SortAttribute : Attribute
19 | {
20 | public SortAttribute(SortType sortType)
21 | {
22 | SortType = sortType;
23 | }
24 |
25 | public readonly SortType SortType;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/StacMan/StacMan.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | True
6 | StacMan
7 | 1.1.2
8 | Emmett Nicholas;Marc Gravell
9 | StacMan is a .NET client for Stack Exchange API v2
10 | Copyright 2012
11 | https://github.com/StackExchange/StacMan
12 | http://i.stack.imgur.com/M3cQG.png
13 | StackExchange.StacMan
14 | True
15 | https://github.com/StackExchange/StacMan.git
16 | git
17 | Stack;Exchange;Overflow;API;StackExchange;StackOverflow
18 | - 1.1.2: adds support for per-request url inspection and manipulation via SetUrlManager
19 | MIT
20 |
21 |
22 |
23 |
24 |
25 |
26 | True
27 | True
28 | Methods.tt
29 |
30 |
31 | TextTemplatingFileGenerator
32 | Methods.ignore
33 |
34 |
35 | True
36 | True
37 | Types.tt
38 |
39 |
40 | TextTemplatingFileGenerator
41 | Types.ignore
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/StacMan/StacManClient.ApiRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace StackExchange.StacMan
7 | {
8 | public partial class StacManClient
9 | {
10 | private enum HttpMethod
11 | {
12 | GET,
13 | POST
14 | }
15 |
16 | private interface IApiRequest
17 | {
18 | void GetResponse(Action callback);
19 | string BackoffKey { get; }
20 | }
21 |
22 | private class ApiRequest : IApiRequest where T : StacManType
23 | {
24 | public ApiRequest(StacManClient client, ApiUrlBuilder ub, HttpMethod httpMethod, string backoffKey)
25 | {
26 | Client = client;
27 | UrlBuilder = ub;
28 | HttpMethod = httpMethod;
29 | BackoffKey = backoffKey;
30 | }
31 |
32 | private readonly StacManClient Client;
33 | private readonly ApiUrlBuilder UrlBuilder;
34 | private readonly HttpMethod HttpMethod;
35 |
36 | private readonly TaskCompletionSource> Tcs = new TaskCompletionSource>();
37 |
38 | public Task> Task
39 | {
40 | get { return Tcs.Task; }
41 | }
42 |
43 | public void GetResponse(Action callback)
44 | {
45 | try
46 | {
47 | Client.GetApiResponse(UrlBuilder, HttpMethod, BackoffKey, response =>
48 | {
49 | try
50 | {
51 | callback();
52 | Tcs.SetResult(response);
53 | }
54 | catch (Exception ex)
55 | {
56 | Tcs.SetException(ex);
57 | }
58 | });
59 | }
60 | catch (Exception ex)
61 | {
62 | callback();
63 | Tcs.SetException(ex);
64 | }
65 | }
66 |
67 | public string BackoffKey { get; private set; }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/StacMan/StacManClient.Validation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace StackExchange.StacMan
6 | {
7 | public partial class StacManClient
8 | {
9 | private void ValidateMinApiVersion(string minApiVersion)
10 | {
11 | double clientApiVersion;
12 | double methodApiVersion;
13 |
14 | if (Double.TryParse(Version, out clientApiVersion) && Double.TryParse(minApiVersion, out methodApiVersion) && methodApiVersion > clientApiVersion)
15 | throw new InvalidOperationException("method introduced in API version " + minApiVersion);
16 | }
17 |
18 | private void ValidatePaging(int? page, int? pagesize)
19 | {
20 | if (page.HasValue && page.Value < 1)
21 | throw new ArgumentException("page must be positive", "page");
22 |
23 | if (pagesize.HasValue && pagesize.Value < 0)
24 | throw new ArgumentException("pagesize cannot be negative", "pagesize");
25 | }
26 |
27 | private void ValidateString(string value, string paramName)
28 | {
29 | if (value == null)
30 | throw new ArgumentNullException(paramName);
31 |
32 | if (value == "")
33 | throw new ArgumentException(paramName + " cannot be empty", paramName);
34 | }
35 |
36 | private void ValidateEnumerable(IEnumerable values, string paramName)
37 | {
38 | if (values == null)
39 | throw new ArgumentNullException(paramName);
40 |
41 | if (!values.Any())
42 | throw new ArgumentException(paramName + " cannot be empty", paramName);
43 | }
44 |
45 | private void ValidateSortMinMax(TSort? sort,
46 | int? min = null, int? max = null,
47 | DateTime? mindate = null, DateTime? maxdate = null,
48 | string minname = null, string maxname = null,
49 | Badges.Rank? minrank = null, Badges.Rank? maxrank = null,
50 | Badges.BadgeType? mintype = null, Badges.BadgeType? maxtype = null)
51 | where TSort : struct // proxy for "where TSort: enum"
52 | {
53 | if (!typeof(TSort).IsEnum)
54 | throw new ArgumentException("sort must be a nullable enumeration", "sort");
55 |
56 | var sortsBySortType = ReflectionCache.SortsBySortType.Value;
57 | var sortActual = sort ?? default(TSort);
58 |
59 | if (!sortsBySortType.ContainsKey(SortType.DateTime) || !sortsBySortType[SortType.DateTime].Contains(sortActual))
60 | {
61 | if (mindate.HasValue)
62 | throw new ArgumentException("mindate must be null when sort=" + sortActual.ToString().ToLower(), "mindate");
63 | if (maxdate.HasValue)
64 | throw new ArgumentException("maxdate must be null when sort=" + sortActual.ToString().ToLower(), "maxdate");
65 | }
66 |
67 | if (!sortsBySortType.ContainsKey(SortType.Integer) || !sortsBySortType[SortType.Integer].Contains(sortActual))
68 | {
69 | if (min.HasValue)
70 | throw new ArgumentException("min must be null when sort=" + sortActual.ToString().ToLower(), "min");
71 | if (max.HasValue)
72 | throw new ArgumentException("min must be null when sort=" + sortActual.ToString().ToLower(), "max");
73 | }
74 |
75 | if (!sortsBySortType.ContainsKey(SortType.String) || !sortsBySortType[SortType.String].Contains(sortActual))
76 | {
77 | if (minname != null)
78 | throw new ArgumentException("minname must be null when sort=" + sortActual.ToString().ToLower(), "minname");
79 | if (maxname != null)
80 | throw new ArgumentException("maxname must be null when sort=" + sortActual.ToString().ToLower(), "maxname");
81 | }
82 |
83 | if (!sortsBySortType.ContainsKey(SortType.BadgeRank) || !sortsBySortType[SortType.BadgeRank].Contains(sortActual))
84 | {
85 | if (minrank.HasValue)
86 | throw new ArgumentException("minrank must be null when sort=" + sortActual.ToString().ToLower(), "minrank");
87 | if (maxrank.HasValue)
88 | throw new ArgumentException("maxrank must be null when sort=" + sortActual.ToString().ToLower(), "maxrank");
89 | }
90 |
91 | if (!sortsBySortType.ContainsKey(SortType.BadgeType) || !sortsBySortType[SortType.BadgeType].Contains(sortActual))
92 | {
93 | if (mintype.HasValue)
94 | throw new ArgumentException("mintype must be null when sort=" + sortActual.ToString().ToLower(), "mintype");
95 | if (maxtype.HasValue)
96 | throw new ArgumentException("maxtype must be null when sort=" + sortActual.ToString().ToLower(), "maxtype");
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/StacMan/StacManResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace StackExchange.StacMan
7 | {
8 | ///
9 | /// StacMan API response
10 | ///
11 | public class StacManResponse where T : StacManType
12 | {
13 | ///
14 | /// True if the API call was successful.
15 | ///
16 | public bool Success { get; internal set; }
17 |
18 | ///
19 | /// Data returned by the Stack Exchange API method.
20 | ///
21 | public Wrapper Data { get; internal set; }
22 |
23 | ///
24 | /// Non-null whenever Success is false.
25 | ///
26 | public Exception Error { get; internal set; }
27 |
28 | ///
29 | /// True if the underlying Stack Exchange API method responded, regardless of success.
30 | ///
31 | public bool ReceivedApiResponse
32 | {
33 | get { return Data != null; }
34 | }
35 |
36 | #region Properties for debugging
37 |
38 | ///
39 | /// The url of the underlying Stack Exchange API method.
40 | /// Useful for debugging.
41 | ///
42 | public string ApiUrl { get; internal set; }
43 |
44 | ///
45 | /// Response of the request made to the underlying Stack Exchange API method.
46 | /// Useful for debugging.
47 | ///
48 | public string RawData { get; internal set; }
49 |
50 | #endregion
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/StacMan/StacManType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace StackExchange.StacMan
5 | {
6 | ///
7 | /// Empty base class for ease of StacMan design.
8 | /// Nothing to see here, move along.
9 | ///
10 | public abstract class StacManType
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/StacMan/Stackie.t4properties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | StackieTypes.tt
6 | Host
7 | VisualStudio
8 |
9 |
10 | StackieMethods.tt
11 | Host
12 | VisualStudio
13 |
14 |
15 |
--------------------------------------------------------------------------------
/StacMan/SuggestedEdits/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.SuggestedEdits
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// creation_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Creation,
13 |
14 | ///
15 | /// approval_date (does not return unapproved suggested_edits)
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Approval,
19 |
20 | ///
21 | /// rejection_date (does not return unrejected suggested_edits)
22 | ///
23 | [Sort(SortType.DateTime)]
24 | Rejection
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/TagSynonyms/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.TagSynonyms
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// creation_date
10 | ///
11 | [Sort(SortType.DateTime)]
12 | Creation,
13 |
14 | ///
15 | /// applied_count
16 | ///
17 | [Sort(SortType.Integer)]
18 | Applied,
19 |
20 | ///
21 | /// last_applied_date
22 | ///
23 | [Sort(SortType.DateTime)]
24 | Activity
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/Tags/Period.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Tags
2 | {
3 | ///
4 | /// period
5 | ///
6 | public enum Period
7 | {
8 | ///
9 | /// all_time
10 | ///
11 | AllTime,
12 |
13 | ///
14 | /// month
15 | ///
16 | Month
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/StacMan/Tags/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Tags
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// count
10 | ///
11 | [Sort(SortType.Integer)]
12 | Popular,
13 |
14 | ///
15 | /// the creation_date of the last question asked with the tag
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Activity,
19 |
20 | ///
21 | /// name
22 | ///
23 | [Sort(SortType.String)]
24 | Name
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/StacMan/UserTimelines/TimelineType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.UserTimelines
2 | {
3 | ///
4 | /// timeline_type
5 | ///
6 | public enum TimelineType
7 | {
8 | ///
9 | /// commented
10 | ///
11 | Commented,
12 |
13 | ///
14 | /// asked
15 | ///
16 | Asked,
17 |
18 | ///
19 | /// answered
20 | ///
21 | Answered,
22 |
23 | ///
24 | /// badge
25 | ///
26 | Badge,
27 |
28 | ///
29 | /// revision
30 | ///
31 | Revision,
32 |
33 | ///
34 | /// accepted
35 | ///
36 | Accepted,
37 |
38 | ///
39 | /// reviewed
40 | ///
41 | Reviewed,
42 |
43 | ///
44 | /// suggested
45 | ///
46 | Suggested
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/StacMan/Users/Sort.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Users
2 | {
3 | ///
4 | /// sort
5 | ///
6 | public enum Sort
7 | {
8 | ///
9 | /// reputation
10 | ///
11 | [Sort(SortType.Integer)]
12 | Reputation,
13 |
14 | ///
15 | /// creation_date
16 | ///
17 | [Sort(SortType.DateTime)]
18 | Creation,
19 |
20 | ///
21 | /// display_name
22 | ///
23 | [Sort(SortType.String)]
24 | Name,
25 |
26 | ///
27 | /// last_modified_date
28 | ///
29 | [Sort(SortType.DateTime)]
30 | Modified
31 | }
32 | }
--------------------------------------------------------------------------------
/StacMan/Users/UserType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Users
2 | {
3 | ///
4 | /// user_type
5 | ///
6 | public enum UserType
7 | {
8 | ///
9 | /// unregistered
10 | ///
11 | Unregistered,
12 |
13 | ///
14 | /// registered
15 | ///
16 | Registered,
17 |
18 | ///
19 | /// moderator
20 | ///
21 | Moderator,
22 |
23 | ///
24 | /// does_not_exist
25 | ///
26 | DoesNotExist
27 | }
28 | }
--------------------------------------------------------------------------------
/StacMan/filters/FilterType.cs:
--------------------------------------------------------------------------------
1 | namespace StackExchange.StacMan.Filters
2 | {
3 | ///
4 | /// filter_type
5 | ///
6 | public enum FilterType
7 | {
8 | ///
9 | /// safe
10 | ///
11 | Safe,
12 |
13 | ///
14 | /// unsafe
15 | ///
16 | Unsafe,
17 |
18 | ///
19 | /// invalid
20 | ///
21 | Invalid
22 | }
23 | }
--------------------------------------------------------------------------------
/TraceAndTestImpact.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | These are test settings for Trace and Test Impact.
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007. Clarius Consulting, Manas Technology Solutions, InSTEDD
2 | http://code.google.com/p/moq/
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms,
6 | with or without modification, are permitted provided
7 | that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the
10 | above copyright notice, this list of conditions and
11 | the following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce
14 | the above copyright notice, this list of conditions
15 | and the following disclaimer in the documentation
16 | and/or other materials provided with the distribution.
17 |
18 | * Neither the name of Clarius Consulting, Manas Technology Solutions or InSTEDD nor the
19 | names of its contributors may be used to endorse
20 | or promote products derived from this software
21 | without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 | SUCH DAMAGE.
37 |
38 | [This is the BSD license, see
39 | http://www.opensource.org/licenses/bsd-license.php]
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/Moq.4.0.10827.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/Moq.4.0.10827.nupkg
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/Moq.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/Moq.chm
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET35/Moq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/NET35/Moq.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET35/Moq.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/NET35/Moq.pdb
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET40/Moq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/NET40/Moq.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET40/Moq.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/NET40/Moq.pdb
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Castle.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/Silverlight4/Castle.Core.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/StackExchange/StacMan/94e30128202dfc58fd7c21f709206bed4a23ea52/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.pdb
--------------------------------------------------------------------------------