Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed issue #1

  • Loading branch information...
commit 9ab8381d48d3e6dbe9cf745d9c1cb9888dc3e933 1 parent 6521062
@bevacqua authored
View
BIN  Solution/BridgeStack.suo
Binary file not shown
View
5 Solution/BridgeStack/DataContracts/Json/Basic/IApiResponse.cs
@@ -29,6 +29,11 @@ public interface IApiResponse : IHttpResponse
[JsonIgnore]
ResultSourceEnum Source { get; set; }
/// <summary>
+ /// The <see cref="IStackClient"/> which produced this API response.
+ /// </summary>
+ [JsonIgnore]
+ IStackClient SourceClient { get; set; }
+ /// <summary>
/// The remaining amount of API calls that can be executed.
/// </summary>
[JsonProperty("quota_remaining")]
View
1  Solution/BridgeStack/DataContracts/Json/INetworkSite.cs
@@ -28,6 +28,7 @@ public interface INetworkSite<TStyling, TRelation>
/// <summary>
/// The type of site.
/// </summary>
+ [JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("site_type")]
SiteTypeEnum? SiteType { get; set; }
/// <summary>
View
2  Solution/BridgeStack/DataContracts/Json/INetworkSiteStyling.cs
@@ -23,6 +23,6 @@ public interface INetworkSiteStyling
/// Background color for tags.
/// </summary>
[JsonProperty("tag_background_color")]
- String TagBackgroundColor { get; set; }
+ string TagBackgroundColor { get; set; }
}
}
View
6 Solution/BridgeStack/Entity/ApiEndpointBuilder/ApiEndpointBuilder.cs
@@ -117,12 +117,13 @@ public ApiEndpointBuilder(IStackClient client, ApiMethodEnum? method, string app
ApiMethod = method.Value;
AppKey = appKey;
AccessToken = accessToken;
+ _out = new Lazy<string>(Build);
}
/// <summary>
/// The API endpoint built by this instance of an API endpoint builder.
/// </summary>
- private string _out;
+ private Lazy<string> _out;
/// <summary>
/// Builds and returns the target endpoint Uri.
@@ -141,7 +142,6 @@ private string Build()
}
string parameters = BuildParameters();
string endpoint = EndpointBuilder.Endpoint.FormatWith(ApiEndpoint, method, parameters);
- _out = endpoint;
return endpoint;
}
@@ -211,7 +211,7 @@ public IApiEndpointBuilder Vectorized(ICollection<IRequestVector> vectors)
/// <returns>The endpoint successfully built, or throws an exception.</returns>
public override string ToString()
{
- return _out ?? Build();
+ return _out.Value;
}
}
}
View
2  Solution/BridgeStack/Entity/EventLog/EventLog.cs
@@ -119,7 +119,7 @@ public void FatalFormat(string message, params string[] args)
/// Invokes <see cref="OnEventLogged"/> on all associated event delegates.
/// </summary>
/// <param name="args">The event arguments.</param>
- private void InvokeEventLogged(OnEventLoggedArgs args)
+ internal void InvokeEventLogged(OnEventLoggedArgs args)
{
if (OnEventLogged != null)
OnEventLogged(Client, args);
View
8 Solution/BridgeStack/Entity/Json/Basic/ApiResponse.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using BridgeStack;
namespace BridgeStack
{
@@ -25,6 +24,11 @@ public sealed class ApiResponse<T> : IApiResponse<T> where T : class
public ResultSourceEnum Source { get; set; }
/// <summary>
+ /// The <see cref="IStackClient"/> which produced this API response.
+ /// </summary>
+ public IStackClient SourceClient { get; set; }
+
+ /// <summary>
/// The remaining amount of API calls that can be executed.
/// </summary>
public long? QuotaRemaining { get; set; }
@@ -50,7 +54,7 @@ public sealed class ApiResponse<T> : IApiResponse<T> where T : class
public long? Total { get; set; }
/// <summary>
- /// The type of elements being returned in the <see cref="IApiResponse{T}.Items"/> collection.
+ /// The type of elements being returned in the <see cref="IApiResponse{T}.Items"/> collection.
/// </summary>
public string Type { get; set; }
View
28 Solution/BridgeStack/RequestHandler/RequestHandler.cs
@@ -43,14 +43,14 @@ internal sealed class RequestHandler : IRequestHandler
{
throw new ArgumentNullException("builder");
}
- IApiResponse<T> result = null;
+ IApiResponse<T> response = null;
try
{
- result = InternalProcessing<T>(builder); // Source = Api | Cache
+ response = InternalProcessing<T>(builder); // Source = Api | Cache
}
catch (BridgeException api)
{
- result = new ApiResponse<T> // Source = BridgeException
+ response = new ApiResponse<T> // Source = BridgeException
{
Exception = api,
Source = ResultSourceEnum.BridgeException
@@ -58,16 +58,20 @@ internal sealed class RequestHandler : IRequestHandler
}
catch (WebException web)
{
- result = HandleWebException<T>(web); // Source = ApiException
+ response = HandleWebException<T>(web); // Source = ApiException
}
finally
{
- if (result != null && result.Source != ResultSourceEnum.Cache)
+ if (response != null)
{
- Client.Cache.Push(builder, result);
+ response.SourceClient = Client;
+ if (response.Source != ResultSourceEnum.Cache)
+ {
+ Client.Cache.Push(builder, response);
+ }
}
}
- return result;
+ return response;
}
/// <summary>
@@ -78,8 +82,8 @@ internal sealed class RequestHandler : IRequestHandler
/// <returns>The API response object.</returns>
private IApiResponse<T> InternalProcessing<T>(IApiEndpointBuilder builder) where T : class
{
- IApiResponse<T> result = FetchFromCache<T>(builder);
- return result ?? FetchFromThrottler<T>(builder);
+ IApiResponse<T> response = FetchFromCache<T>(builder);
+ return response ?? FetchFromThrottler<T>(builder);
}
/// <summary>
@@ -93,9 +97,9 @@ internal sealed class RequestHandler : IRequestHandler
IResponseCacheItem<T> cacheItem = Client.Cache.Get<T>(builder, true);
if (cacheItem != null)
{
- IApiResponse<T> result = cacheItem.Response;
- result.Source = ResultSourceEnum.Cache;
- return result;
+ IApiResponse<T> response = cacheItem.Response;
+ response.Source = ResultSourceEnum.Cache;
+ return response;
}
return null;
}
View
2  Solution/BridgeStack/StackClient/StackClientBase.cs
@@ -15,7 +15,7 @@ internal abstract class StackClientBase : IStackClient
/// <summary>
/// Request throttler implementation instance.
/// </summary>
- public IRequestThrottler Throttler { get; protected set; }
+ public IRequestThrottler Throttler { get; protected internal set; }
/// <summary>
/// The application's key. Grants a higher request quota.
View
11 bridgestack.txt
@@ -0,0 +1,11 @@
+HIGH intelli-filtering (and intelli-loading? how..)
+med ext methods to load answers for questions, etc.
+is yield enough?
+
+HIGH parallel-enabled dedicated client, is this even needed?
+
+MED: remove auth stackclient, favor route attributes telling to
+the endpointbuilder whether the method endpoint requires auth
+
+
+MED: remover client / parent de clases, pasar por ctor -> inyectar luego
View
5 links.txt
@@ -0,0 +1,5 @@
+https://github.com/bevacqua/BridgeStack
+
+http://stackapps.com/questions/2945/bridgestack-net-client-library-with-full-2-0-support
+
+https://api.stackexchange.com/docs
Please sign in to comment.
Something went wrong with that request. Please try again.