提交 0237a030 编写于 作者: J Josh Peterson

The NetworkChange event is not supported on Windows (case 1278048)

Provide a proper `PlatformNotSupported` exception for the
`NetworkChange` event on Windows, as it is not currently supported.
上级 285a344d
......@@ -107,6 +107,8 @@ namespace System.Net.NetworkInformation {
if (networkChange != null)
return;
if (IsWindows)
throw new PlatformNotSupportedException ("NetworkInformation.NetworkChange is not supported on the current platform.");
try {
networkChange = new MacNetworkChange ();
} catch {
......@@ -117,6 +119,21 @@ namespace System.Net.NetworkInformation {
#endif // MONOTOUCH_WATCH
}
static bool IsWindows
{
get
{
PlatformID platform = Environment.OSVersion.Platform;
if (platform == PlatformID.Win32S ||
platform == PlatformID.Win32Windows ||
platform == PlatformID.Win32NT ||
platform == PlatformID.WinCE) {
return true;
}
return false;
}
}
static void MaybeDispose ()
{
if (networkChange != null && networkChange.HasRegisteredEvents) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册