当前位置: 首页>>代码示例>>C#>>正文


C# NetworkReachabilityFlags.HasFlag方法代码示例

本文整理汇总了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 ();
		}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:10,代码来源:MainWindowController.cs

示例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" : "-"
         );
 }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:24,代码来源:Reachability.cs

示例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
        }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:15,代码来源:Reachability.cs

示例4: ReachableViaWWAN

        private bool ReachableViaWWAN(NetworkReachabilityFlags flags)
        {
            if (!HasWWAN)
                return false;

            return (flags.HasFlag(NetworkReachabilityFlags.Reachable) && flags.HasFlag(NetworkReachabilityFlags.IsWWAN));
        }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:7,代码来源:Reachability.cs

示例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;
        }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:35,代码来源:Reachability.cs


注:本文中的NetworkReachabilityFlags.HasFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。