简体   繁体   English

WP8.1和拦截器

[英]WP8.1 and interceptors

I'm developing a Windows Phone 8.1 app and I have to check some informations before executing some methods (I have to check if the internet connection is available and if the localization is active). 我正在开发Windows Phone 8.1应用程序,必须在执行某些方法之前检查一些信息(我必须检查Internet连接是否可用以及本地化是否处于活动状态)。 There are interceptors or another way to programmatically execute a method before some actions in wp8.1? 在wp8.1中执行某些操作之前,是否有拦截器或其他方法可以以编程方式执行方法?

The .NET platform has something called Code Contracts. .NET平台有一个称为代码合同的代码。 Basically, starting from .NET 4.0, you can use Contract.Requires(Boolean) to verify if a precondition is active. 基本上,从.NET 4.0开始,可以使用Contract.Requires(Boolean)来验证前提条件是否处于活动状态。 You can even show a special message to the user when it's not active. 您甚至可以在不活动时向用户显示一条特殊消息。

For more info, there's http://msdn.microsoft.com/en-us/library/dd264808(v=vs.110).aspx on MSDN, and of course Google. 有关更多信息,请参见MSDN上的http://msdn.microsoft.com/en-us/library/dd264808(v=vs.110).aspx ,当然还有Google。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM