本文整理汇总了C#中NetworkReachabilityFlags.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReachabilityFlags.HasFlag方法的具体用法?C# NetworkReachabilityFlags.HasFlag怎么用?C# NetworkReachabilityFlags.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkReachabilityFlags
的用法示例。
在下文中一共展示了NetworkReachabilityFlags.HasFlag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateReachability
void UpdateReachability (NetworkReachabilityFlags flags, NSImageView icon, NSTextField statusField)
{
if (flags.HasFlag (NetworkReachabilityFlags.Reachable) && !flags.HasFlag (NetworkReachabilityFlags.ConnectionRequired)) {
icon.Image = NSImage.ImageNamed ("connected");
} else {
icon.Image = NSImage.ImageNamed ("disconnected");
}
statusField.StringValue = flags == 0 ? String.Empty : flags.ToString ();
}
示例2: GetFlagsAsString
/// <summary>
/// Utility method that gets the flags as a string
/// </summary>
/// <returns>
/// The flags as string
/// </returns>
/// <param name='flags'>
/// Flags
/// </param>
protected string GetFlagsAsString(NetworkReachabilityFlags flags)
{
return string.Concat(
!HasWWAN ? "X" : flags.HasFlag(NetworkReachabilityFlags.IsWWAN) ? "W" : "-",
flags.HasFlag(NetworkReachabilityFlags.Reachable) ? "R" : "-",
" ",
flags.HasFlag(NetworkReachabilityFlags.ConnectionRequired) ? "c" : "-",
flags.HasFlag(NetworkReachabilityFlags.TransientConnection) ? "t" : "-",
flags.HasFlag(NetworkReachabilityFlags.InterventionRequired) ? "i" : "-",
flags.HasFlag(NetworkReachabilityFlags.ConnectionOnTraffic) ? "C" : "-",
flags.HasFlag(NetworkReachabilityFlags.ConnectionOnDemand) ? "D" : "-",
flags.HasFlag(NetworkReachabilityFlags.IsLocalAddress) ? "l" : "-",
flags.HasFlag(NetworkReachabilityFlags.IsDirect) ? "d" : "-"
);
}
示例3: ReachableViaWiFi
private bool ReachableViaWiFi(NetworkReachabilityFlags flags)
{
if (!flags.HasFlag(NetworkReachabilityFlags.Reachable))
return false;
// If we don't have WWAN, reachable = WiFi (close enough)
if (!HasWWAN)
return true;
// We have WWAN, if we're connecting through WWAN, we're not connecting through WiFi
if (flags.HasFlag(NetworkReachabilityFlags.IsWWAN))
return false;
else
return true; // Connecting through WiFi, not WWAN
}
示例4: ReachableViaWWAN
private bool ReachableViaWWAN(NetworkReachabilityFlags flags)
{
if (!HasWWAN)
return false;
return (flags.HasFlag(NetworkReachabilityFlags.Reachable) && flags.HasFlag(NetworkReachabilityFlags.IsWWAN));
}
示例5: IsReachableWithFlags
/// <summary>
/// Get whether the requested resource is reachable with the specified flags
/// </summary>
/// <returns>
/// <c>true</c> if the requested resource is reachable with the specified flags; otherwise, <c>false</c>.
/// </returns>
/// <param name='flags'>
/// Reachability flags.
/// </param>
/// <remarks>
/// This is for the case where you flick the airplane mode you end up getting something like this:
/// Reachability: WR ct-----
/// Reachability: -- -------
/// Reachability: WR ct-----
/// Reachability: -- -------
/// We treat this as 4 UNREACHABLE triggers - really Apple should do better than this
/// </remarks>
private bool IsReachableWithFlags(NetworkReachabilityFlags flags)
{
if (!flags.HasFlag(NetworkReachabilityFlags.Reachable))
return false;
var testCase = NetworkReachabilityFlags.ConnectionRequired | NetworkReachabilityFlags.TransientConnection;
if ((flags & testCase) == testCase)
return false;
if (HasWWAN)
{
// If we're connecting via WWAN, and WWAN doesn't count as connected, return false
if (flags.HasFlag(NetworkReachabilityFlags.IsWWAN) && !AllowWWAN)
return false;
}
return true;
}