我一直在阅读关于使用Azure的自定义auth方法,并偶然发现12 Days of ZUMO。这是一个很好的写作,但我似乎无法在当前的.Net客户端SDK for Azure中找到与IServiceFilter相关的任何内容。Azure移动服务过滤器 - 删除?
我正在用C#开发一个Xamarin应用程序。
此功能已被移除或重新定位?我引用了所有Azure命名空间,并且intellisense无法找到IServiceFilter或与服务过滤器相关的任何其他内容。
感谢您的阅读。
我一直在阅读关于使用Azure的自定义auth方法,并偶然发现12 Days of ZUMO。这是一个很好的写作,但我似乎无法在当前的.Net客户端SDK for Azure中找到与IServiceFilter相关的任何内容。Azure移动服务过滤器 - 删除?
我正在用C#开发一个Xamarin应用程序。
此功能已被移除或重新定位?我引用了所有Azure命名空间,并且intellisense无法找到IServiceFilter或与服务过滤器相关的任何其他内容。
感谢您的阅读。
我目前正在为Java开发一个Android应用程序(我不认为这个C#库是非常不同的)。 而且我可以访问ServiceFilter。但是我没有看到IServiceFilter。
命名空间 - com.microsoft.windowsazure.mobileservices.http.ServiceFilter
库版本 - 2.0.2-β2
在Xamarin,你需要使用DelegateHandler
代替。这是过滤http流量的标准.net方式。
Client = new MobileServiceClient (API_URL, new MyExistingHandler());
到:
Client = new MobileServiceClient (API_URL, new MyLogFilter(), new MyExistingHandler());
public class MyLogFilter : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
// Do any pre-request requirements here
Log.Warning("http request", request.RequestUri.ToString());
// Request happens here
var response = await base.SendAsync(request, cancellationToken);
// Do any post-request requirements here
Log.Warning("http response", response.StatusCode + " " + response.Content.ReadAsStringAsync().Result);
return response;
}
}
一旦你做到了这一点,你初始化你的MobileServiceClient
时,改变这只是链中的处理程序