Windows phone 7 在windows phone中订阅所有web请求

Windows phone 7 在windows phone中订阅所有web请求,windows-phone-7,httpwebrequest,Windows Phone 7,Httpwebrequest,是否可以在windows phone应用程序中订阅所有web请求? 我的意思是注册一个全局钩子,它将在每次我向web服务器发出请求时触发。非常感谢简单的例子: // Since the property is static, it will be shared by all instances of WebClientWrapper // Set this before creating an instance of WebClientWrapper WebClientWrapper.Hook

是否可以在windows phone应用程序中订阅所有web请求? 我的意思是注册一个全局钩子,它将在每次我向web服务器发出请求时触发。非常感谢

简单的例子:

// Since the property is static, it will be shared by all instances of WebClientWrapper
// Set this before creating an instance of WebClientWrapper
WebClientWrapper.Hook = address => Debug.WriteLine(address);

var webClientWrapper = new WebClientWrapper();
webClientWrapper.DownloadString("http://www.something.com");



public class WebClientWrapper
{
    private readonly WebClient _webClient;

    // This can be string, your custom class of whatever you need
    public static Action<string> Hook { get; set; }

    public WebClientWrapper()
    {
        _webClient = new WebClient();
    }

    public string DownloadString(string address)
    {
        Hook(address);
        return _webClient.DownloadString(address);
    }
}
//由于该属性是静态的,因此它将由WebClient Rapper的所有实例共享
//在创建WebClient Rapper实例之前设置此选项
WebClientWrapper.Hook=address=>Debug.WriteLine(地址);
var webClientWrapper=新的webClientWrapper();
WebClientRapper.DownloadString(“http://www.something.com");
公共类网络客户端说话者
{
私有只读网络客户端_网络客户端;
//这可以是string,它是您所需的自定义类
公共静态操作挂钩{get;set;}
公共网络客户端说话者()
{
_webClient=新的webClient();
}
公共字符串下载字符串(字符串地址)
{
钩子(地址);
返回_webClient.DownloadString(地址);
}
}