lfoust avatar lfoust committed c0e00a7

Finished the .net 3.5 async methods

Comments (0)

Files changed (6)

Add a comment to this file

trunk/data/V2.0 Upgrade Checklist.xlsx

Binary file modified.

trunk/source/Stacky.Net35/Stacky.Net35.csproj

     <Compile Include="..\Stacky\Sites.cs">
       <Link>Sites.cs</Link>
     </Compile>
-    <Compile Include="..\Stacky\StackyClientAsync\NetworkMethods.cs">
-      <Link>StackyClientAsync\NetworkMethods.cs</Link>
-    </Compile>
     <Compile Include="..\Stacky\StackyClientAsync\PrivilegeMethods.cs">
       <Link>StackyClientAsync\PrivilegeMethods.cs</Link>
     </Compile>
     <Compile Include="StackyClientAsync\AnswerMethods.cs" />
     <Compile Include="StackyClientAsync\BadgeMethods.cs" />
     <Compile Include="StackyClientAsync\CommentMethods.cs" />
+    <Compile Include="StackyClientAsync\NetworkMethods.cs" />
     <Compile Include="StackyClientAsync\PostMethods.cs" />
     <Compile Include="StackyClientAsync\QuestionMethods.cs" />
     <Compile Include="StackyClientAsync\RevisionMethods.cs" />
     <Compile Include="StackyClientAsync\StackyClientWithOptions.cs" />
     <Compile Include="StackyClientAsync\StatsMethods.cs" />
+    <Compile Include="StackyClientAsync\SuggestedEditMethods.cs" />
     <Compile Include="StackyClientAsync\TagMethods.cs" />
     <Compile Include="StackyClientAsync\UserMethods.cs" />
     <Compile Include="StackyClient\AnswerMethods.cs" />

trunk/source/Stacky.Net35/StackyClientAsync/NetworkMethods.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Stacky
+{
+#if SILVERLIGHT
+    public partial class StackyClient
+#else
+    public partial class StackyClientAsync
+#endif
+    {
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/invalidate-access-tokens
+        /// </summary>
+        public void InvalidateAccessTokens(IEnumerable<string> tokens, Action<IPagedList<AccessToken>> onSuccess, Action<ApiException> onError, Options options)
+        {
+            MakeRequest<AccessToken>("access-tokens", new string[] { tokens.Vectorize(), "invalidate" }, new
+            {
+                page = options.Page ?? null,
+                pagesize = options.PageSize ?? null,
+                filter = options.Filter
+            }, response => onSuccess(new PagedList<AccessToken>(response)), onError);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/invalidate-access-tokens
+        /// </summary>
+        public void InvalidateAccessToken(string token, Action<AccessToken> onSuccess, Action<ApiException> onError, Options options)
+        {
+            InvalidateAccessTokens(new string[] { token }, items => onSuccess(items.FirstOrDefault()), onError, options);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/read-access-tokens
+        /// </summary>
+        public void ReadAccessTokens(IEnumerable<string> tokens, Action<IPagedList<AccessToken>> onSuccess, Action<ApiException> onError, Options options)
+        {
+            MakeRequest<AccessToken>("access-tokens", new string[] { tokens.Vectorize(), "read" }, new
+            {
+                page = options.Page ?? null,
+                pagesize = options.PageSize ?? null,
+                filter = options.Filter
+            }, response => onSuccess(new PagedList<AccessToken>(response)), onError);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/read-access-tokens
+        /// </summary>
+        public void ReadAccessToken(string token, Action<AccessToken> onSuccess, Action<ApiException> onError, Options options)
+        {
+            ReadAccessTokens(new string[] { token }, items => onSuccess(items.FirstOrDefault()), onError, options);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/create-filter
+        /// </summary>
+        public void CreateFilter(IEnumerable<string> include, IEnumerable<string> exclude, Action<Filter> onSuccess, Action<ApiException> onError, string baseFilter, bool? isUnsafe)
+        {
+            MakeRequest<Filter>("similar", null, new
+            {
+                include = include.TryVectorize(),
+                exclude = exclude.TryVectorize(),
+                @base = baseFilter,
+                @unsafe = isUnsafe
+            }, response => onSuccess(response.Items.FirstOrDefault()), onError);
+        }
+
+        /// <summary>
+        /// http://api.stackexchange.com/docs/read-filter
+        /// </summary>
+        public void GetFilters(IEnumerable<string> filters, Action<IEnumerable<Filter>> onSuccess, Action<ApiException> onError, string filter)
+        {
+            MakeRequest<Filter>("similar", new string[] { filters.Vectorize() }, new
+            {
+                filter = filter
+            }, response => onSuccess(response.Items), onError);
+        }
+
+        /// <summary>
+        /// http://api.stackexchange.com/docs/read-filter
+        /// </summary>
+        public void GetFilters(string filter, Action<Filter> onSuccess, Action<ApiException> onError)
+        {
+            GetFilters(new string[] { filter }, items => onSuccess(items.FirstOrDefault()), onError, null);
+        }
+
+        /// <summary>
+        /// See: http://api.stackexchange.com/docs/sites
+        /// </summary>
+        public void GetSites(Action<IPagedList<Site>> onSuccess, Action<ApiException> onError, Options options)
+        {
+            MakeRequest<Site>("sites", null, new
+            {
+                page = options.Page ?? null,
+                pagesize = options.PageSize ?? null,
+                filter = options.Filter
+            }, response => onSuccess(new PagedList<Site>(response)), onError);
+        }
+
+        public void GetAssociatedUsers(IEnumerable<int> ids, Action<IPagedList<NetworkUser>> onSuccess, Action<ApiException> onError, Options options)
+        {
+            MakeRequest<NetworkUser>("users", new string[] { ids.Vectorize(), "associated" }, new
+            {
+                page = options.Page ?? null,
+                pagesize = options.PageSize ?? null,
+                filter = options.Filter
+            }, response => onSuccess(new PagedList<NetworkUser>(response)), onError);
+        }
+
+        public void GetAssociatedUsers(int id, Action<IPagedList<NetworkUser>> onSuccess, Action<ApiException> onError, string filter)
+        {
+            GetAssociatedUsers(id.ToArray(), onSuccess, onError, new Options { Filter = filter });
+        }
+    }
+}

trunk/source/Stacky.Net35/StackyClientAsync/RevisionMethods.cs

     public partial class StackyClientAsync
 #endif
     {
-        public virtual void GetRevisions(IEnumerable<int> ids, Action<IEnumerable<Revision>> onSuccess, Action<ApiException> onError)
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/revisions-by-guids
+        /// </summary>
+        public void GetRevisions(IEnumerable<string> ids, Action<IPagedList<Revision>> onSuccess, Action<ApiException> onError, OptionsWithDates options)
         {
-            GetRevisions(ids, onSuccess, onError, null, null);
+            Execute<Revision>("revisions", new string[] { ids.Vectorize() }, onSuccess, onError, options);
         }
 
-        public virtual void GetRevisions(IEnumerable<int> ids, Action<IEnumerable<Revision>> onSuccess, Action<ApiException> onError, DateTime? fromDate, DateTime? toDate)
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/revisions-by-guids
+        /// </summary>
+        public void GetRevisions(IEnumerable<Guid> ids, Action<IPagedList<Revision>> onSuccess, Action<ApiException> onError, OptionsWithDates options)
         {
-            MakeRequest<Revision>("revisions", new string[] { ids.Vectorize() }, new
-            {
-                site = this.SiteUrlName,
-                fromdate = GetDateValue(fromDate),
-                todate = GetDateValue(toDate),
-            }, (items) => onSuccess(items.Items), onError);
+            GetRevisions(ids.Select(i => i.ToString()), onSuccess, onError, options);
         }
 
-        public virtual void GetRevisions(int id, Action<IEnumerable<Revision>> onSuccess, Action<ApiException> onError)
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/revisions-by-guids
+        /// </summary>
+        public void GetRevision(string id, Action<Revision> onSuccess, Action<ApiException> onError, OptionsWithDates options)
         {
-            GetRevisions(id, onSuccess, onError, null, null);
+            GetRevisions(new string[] { id }, items => onSuccess(items.FirstOrDefault()), onError, options);
         }
 
-        public virtual void GetRevisions(int id, Action<IEnumerable<Revision>> onSuccess, Action<ApiException> onError, DateTime? fromDate, DateTime? toDate)
+        /// <summary>
+        /// See https://api.stackexchange.com/docs/revisions-by-guids
+        /// </summary>
+        public void GetRevision(Guid id, Action<Revision> onSuccess, Action<ApiException> onError, OptionsWithDates options)
         {
-            GetRevisions(id.ToArray(), onSuccess, onError, fromDate, toDate);
-        }
-
-        public virtual void GetRevision(int id, Guid revision, Action<Revision> onSuccess, Action<ApiException> onError)
-        {
-            MakeRequest<Revision>("revisions", new string[] { id.ToString(), revision.ToString() }, new
-            {
-                site = this.SiteUrlName
-            }, returnedItems => onSuccess(returnedItems.Items.FirstOrDefault()), onError);
+            GetRevisions(new string[] { id.ToString() }, items => onSuccess(items.FirstOrDefault()), onError, options);
         }
     }
 }

trunk/source/Stacky.Net35/StackyClientAsync/SuggestedEditMethods.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Stacky
+{
+#if SILVERLIGHT
+    public partial class StackyClient
+#else
+    public partial class StackyClientAsync
+#endif
+    {
+        /// <summary>
+        /// See http://api.stackexchange.com/docs/suggested-edits
+        /// </summary>
+        public void GetSuggestedEdits(Action<IPagedList<SuggestedEdit>> onSuccess, Action<ApiException> onError, Options<SuggestedEditSort> options)
+        {
+            Execute<SuggestedEdit>("suggested-edits", null, onSuccess, onError, options);
+        }
+
+        /// <summary>
+        /// See http://api.stackexchange.com/docs/suggested-edits-by-ids
+        /// </summary>
+        public void GetSuggestedEdits(IEnumerable<int> ids, Action<IPagedList<SuggestedEdit>> onSuccess, Action<ApiException> onError, Options<SuggestedEditSort> options)
+        {
+            Execute<SuggestedEdit>("suggested-edits", new string[] { ids.Vectorize() }, onSuccess, onError, options);
+        }
+
+        /// <summary>
+        /// See http://api.stackexchange.com/docs/suggested-edits-by-ids
+        /// </summary>
+        public void GetSuggestedEdit(int id, Action<SuggestedEdit> onSuccess, Action<ApiException> onError, Options<SuggestedEditSort> options)
+        {
+            GetSuggestedEdits(id.ToArray(), items => onSuccess(items.FirstOrDefault()), onError, options);
+        }
+    }
+}

trunk/source/Stacky/Helpers/UrlHelper.cs

             return String.Join(";", items.Select(i => i.ToString()).ToArray());
         }
 
+        public static string TryVectorize<T>(this IEnumerable<T> items)
+        {
+            if (items == null || items.Count() == 0)
+                return null;
+            return items.Vectorize();
+        }
+
         /// <summary>
         /// Converts an int to int array.
         /// </summary>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.