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


C# NetworkReachabilityFlags类代码示例

本文整理汇总了C#中NetworkReachabilityFlags的典型用法代码示例。如果您正苦于以下问题:C# NetworkReachabilityFlags类的具体用法?C# NetworkReachabilityFlags怎么用?C# NetworkReachabilityFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkReachabilityFlags类属于命名空间,在下文中一共展示了NetworkReachabilityFlags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsReachableWithoutRequiringConnection

        public static bool IsReachableWithoutRequiringConnection (NetworkReachabilityFlags flags)
        {
            // Is it reachable with the current network configuration?
            bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;

            // Do we need a connection to reach it?
            bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;

            // Since the network stack will automatically try to get the WAN up,
            // probe that
            if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                noConnectionRequired = true;

            if (isReachable && noConnectionRequired)
            {
                Application._networkstate = DataAccessLayer.NetworkState.ConnectedWifi;
                if (Application._user != null) 
                    Application._user.NetworkStatus = DataAccessLayer.NetworkState.ConnectedWifi;
            }
            else
            {
                Application._networkstate = DataAccessLayer.NetworkState.Disconnected;
                if (Application._user != null) 
                                   Application._user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
            }

            return isReachable && noConnectionRequired;
        }
开发者ID:MbProg,项目名称:MasterDetailTestProject-IOS-64,代码行数:28,代码来源:Reachability.cs

示例2: OnChange

		static void OnChange(NetworkReachabilityFlags flags)
		{
			var h = ReachabilityChanged;
			if (h != null)
			{
				h(null, EventArgs.Empty);
			}
		}
开发者ID:RobertKozak,项目名称:MonoMobile.Views,代码行数:8,代码来源:Reachablity.cs

示例3: IsNetworkAvailable

		static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
		{
			if (defaultRouteReachability == null) {
				defaultRouteReachability = new NetworkReachability(new IPAddress(0));
				defaultRouteReachability.SetNotification(OnChange);
				defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}
			return defaultRouteReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:9,代码来源:reachability.cs

示例4: IsReachableWithoutRequiringConnection

    public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
    {
        bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;
        bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;

        if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
            noConnectionRequired = true;

        return isReachable && noConnectionRequired;
    }
开发者ID:pmourfield,项目名称:AtlCodeCamp,代码行数:10,代码来源:Reachability.cs

示例5: 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

示例6: IsReachableWithoutRequiringConnection

		/// <summary>
		/// Checks if reachable without requireing a connection
		/// </summary>
		/// <param name="flags"></param>
		/// <returns></returns>
		public static bool IsReachableWithoutRequiringConnection (NetworkReachabilityFlags flags)
		{
			// Is it reachable with the current network configuration?
			bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;

			// Do we need a connection to reach it?
			bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;

			return isReachable && noConnectionRequired;
		}
开发者ID:NateRickard,项目名称:Xamarin.Plugins,代码行数:15,代码来源:Reachability.cs

示例7: IsAdHocWiFiNetworkAvailable

		public static bool IsAdHocWiFiNetworkAvailable (out NetworkReachabilityFlags flags)
		{
			if (adHocWiFiNetworkReachability == null) {
				adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte [] { 169, 254, 0, 0 }));
				adHocWiFiNetworkReachability.SetNotification(OnChange);
				adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}

			return adHocWiFiNetworkReachability.TryGetFlags(out flags) && IsReachableWithoutRequiringConnection(flags);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:10,代码来源:reachability.cs

示例8: OnChange

 static void OnChange (NetworkReachabilityFlags flags)
 {
     var h = ReachabilityChanged;
     if (h != null)
         h (null, EventArgs.Empty);
     if (pictureViewController != null)
     {
         NetworkStatus internetStatus = Reachability.InternetConnectionStatus();
         pictureViewController.UpdateNetwork(internetStatus == NetworkStatus.ReachableViaWiFiNetwork || internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork);
     }
 }
开发者ID:MbProg,项目名称:MasterDetailTestProject-IOS-64,代码行数:11,代码来源:Reachability.cs

示例9: NetworkStatusHelper

        private NetworkStatus NetworkStatusHelper(NetworkReachabilityFlags flags)
        {
            if (!IsReachableWithoutRequiringConnection(flags))
                _networkStatus = NetworkStatus.NotReachable;
            else if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                _networkStatus = NetworkStatus.ReachableViaCarrierDataNetwork;
            else
                _networkStatus = NetworkStatus.ReachableViaWiFiNetwork;

            return _networkStatus;
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:11,代码来源:NetworkReachability.cs

示例10: IsAdHocWiFiNetworkAvailable

    //
    // Returns true if it is possible to reach the AdHoc WiFi network
    // and optionally provides extra network reachability flags as the
    // out parameter
    //
    public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
    {
        if (_adHocWiFiNetworkReachability == null) {
            _adHocWiFiNetworkReachability = new NetworkReachability (new IPAddress (new byte[] { 169, 254, 0, 0 }));
            _adHocWiFiNetworkReachability.SetCallback (OnChange);
            _adHocWiFiNetworkReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
        }

        if (!_adHocWiFiNetworkReachability.TryGetFlags (out flags))
            return false;

        return IsReachableWithoutRequiringConnection (flags);
    }
开发者ID:harryxiaxia,项目名称:ibeaconDemo,代码行数:18,代码来源:Reachability.cs

示例11: HandleReachabilityChanged

		private void HandleReachabilityChanged(NetworkReachabilityFlags flags)
        {
			Console.WriteLine (flags);
            var requiresConnection = (flags & NetworkReachabilityFlags.ConnectionRequired) > 0;
            // It's reachable if Reachable flag is set and no connection is required.
            reachable = !requiresConnection && (flags & NetworkReachabilityFlags.Reachable) > 0;

			// Trigger callback.
			if (this.connectivityChanged != null)
			{
				this.connectivityChanged (reachable);
			}
        }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:13,代码来源:AppleConnectivityServiceImpl.cs

示例12: IsReachableWithoutRequiringConnection

        public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
        {
            // Is it reachable with the current network configuration?
            bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;

            // Do we need a connection to reach it?
            bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;

            // Since the network stack will automatically try to get the WAN up, probe that
            if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
                noConnectionRequired = true;

            return isReachable && noConnectionRequired;
        }
开发者ID:janxl,项目名称:google-analytics-for-monotouch,代码行数:14,代码来源:Reachability+.cs

示例13: IsAdHocWiFiNetworkAvailable

        public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
        {
            if (adHocWiFiNetworkReachability == null)
            {
                adHocWiFiNetworkReachability = new NetworkReachability(new IPAddress(new byte[] {169, 254, 0, 0}));
#warning Need to look at SetNotification instead - ios6 change
                adHocWiFiNetworkReachability.SetNotification(OnChange);
                adHocWiFiNetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
            }

            if (!adHocWiFiNetworkReachability.TryGetFlags(out flags))
                return false;

            return IsReachableWithoutRequiringConnection(flags);
        }
开发者ID:Everbridge,项目名称:sm-MvvmCross,代码行数:15,代码来源:MvxReachability.cs

示例14: IsReachableWithoutRequiringConnection

 /// <summary>
 /// Checks if network is reachable without requiring connection.
 /// </summary>
 /// <param name="flags">
 /// The reachability flags.
 /// </param>
 /// <returns>
 /// True if reachable, false if connection is required.
 /// </returns>
 public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
 {
     return (flags & NetworkReachabilityFlags.Reachable) != 0 &&
         (((flags & NetworkReachabilityFlags.IsWWAN) != 0) || (flags & NetworkReachabilityFlags.ConnectionRequired) == 0);
 }
开发者ID:pooran,项目名称:CustomControls,代码行数:14,代码来源:Reachability.cs

示例15: ReachabilityChanged

 static void ReachabilityChanged(NetworkReachabilityFlags flags)
 {
     FAARegistry.flags = flags;
     haveFlags = true;
 }
开发者ID:pahlot,项目名称:FlightLog,代码行数:5,代码来源:FAARegistry.cs


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