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


C# NetworkReachability.SetNotification方法代码示例

本文整理汇总了C#中NetworkReachability.SetNotification方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReachability.SetNotification方法的具体用法?C# NetworkReachability.SetNotification怎么用?C# NetworkReachability.SetNotification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkReachability的用法示例。


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

示例1: Reachability

 /// <summary>
 /// Initializes a new instance of the <see cref="Reachability.Reachability"/> class.
 /// </summary>
 /// <param name='reachability'>
 /// NetworkReachability instance to use
 /// </param>
 /// <param name='hasWWAN'>
 /// Platform has a WWAN interface
 /// </param>
 protected Reachability(NetworkReachability reachability, bool hasWWAN)
 {
     NetworkReachability = reachability;
     HasWWAN = hasWWAN;
     AllowWWAN = true;
     NetworkReachability.SetNotification(OnReachabilityNotification);
     NetworkReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
 }
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:17,代码来源:Reachability.cs

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

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

示例4: InitializeReachability

		void InitializeReachability ()
		{
			networkReachability = new NetworkReachability (IPAddress.Any);
			networkReachability.SetNotification (flags => UpdateReachability (flags, NetworkIcon, NetworkStatusTextField));
			networkReachability.Schedule ();

			NetworkReachabilityFlags networkReachabilityFlags;
			networkReachability.TryGetFlags (out networkReachabilityFlags);
			UpdateReachability (networkReachabilityFlags, NetworkIcon, NetworkStatusTextField);

			CreateHostReachability ();

			HostTextField.Changed += (sender, e) => CreateHostReachability ();
		}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:14,代码来源:MainWindowController.cs

示例5: 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:nunohorta,项目名称:MvvmCross-Plugins,代码行数:15,代码来源:MvxReachability.cs

示例6: CreateHostReachability

		void CreateHostReachability ()
		{
			if (hostReachability != null) {
				hostReachability.Unschedule ();
				hostReachability.Dispose ();
			}

			if (String.IsNullOrEmpty (HostTextField.StringValue)) {
				HostIcon.Image = NSImage.ImageNamed ("disconnected");
				HostStatusTextField.StringValue = "Enter a host name or IP address";
				return;
			}

			hostReachability = new NetworkReachability (HostTextField.StringValue);
			hostReachability.SetNotification (flags => UpdateReachability (flags, HostIcon, HostStatusTextField));
			hostReachability.Schedule ();

			NetworkReachabilityFlags networkReachabilityFlags;
			networkReachability.TryGetFlags (out networkReachabilityFlags);
			UpdateReachability (networkReachabilityFlags, NetworkIcon, NetworkStatusTextField);
		}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:21,代码来源:MainWindowController.cs

示例7: CreateConnectivityWatchDog

		public void CreateConnectivityWatchDog (Action<bool> connectivityChanged)
		{
			this.connectivityChanged = connectivityChanged;

			if (remoteHostReachability == null)
			{
				if (remoteHostReachability != null)
				{
					remoteHostReachability.Unschedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
				}

				// Create new instance if host address changed.
				remoteHostReachability = new NetworkReachability(new System.Net.IPAddress(0));
				remoteHostReachability.SetNotification(HandleReachabilityChanged);
				remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
			}

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

示例8: RemoteHostStatus

	public static NetworkStatus RemoteHostStatus()
	{
		NetworkReachabilityFlags flags;
		bool reachable;

		if (remoteHostReachability == null)
		{
			remoteHostReachability = new NetworkReachability(HostName);

			// Need to probe before we queue, or we wont get any meaningful values
			// this only happens when you create NetworkReachability from a hostname
			reachable = remoteHostReachability.TryGetFlags(out flags);

			remoteHostReachability.SetNotification(OnChange);
			remoteHostReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
		}
		else
			reachable = remoteHostReachability.TryGetFlags(out flags);			

		if (!reachable)
			return NetworkStatus.NotReachable;

		if (!IsReachableWithoutRequiringConnection(flags))
			return NetworkStatus.NotReachable;

		if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
			return NetworkStatus.ReachableViaCarrierDataNetwork;

		return NetworkStatus.ReachableViaWiFiNetwork;
	}
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:30,代码来源:Reachability.cs

示例9: IsNetworkAvaialable

        private static bool IsNetworkAvaialable(out NetworkReachabilityFlags flags)
        {
            if (defaultRouteReachability == null)
            {
                defaultRouteReachability = new NetworkReachability(new IPAddress(0));
#warning Need to look at SetNotification instead - ios6 change
                defaultRouteReachability.SetNotification(OnChange);
                defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
            }
            if (defaultRouteReachability.TryGetFlags(out flags))
                return false;
            return IsReachableWithoutRequiringConnection(flags);
        }
开发者ID:Everbridge,项目名称:sm-MvvmCross,代码行数:13,代码来源:MvxReachability.cs

示例10: IsNetworkAvailable

        static bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
        {

            if (defaultRouteReachability == null)
            {
                var data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0 };
                var ip = new IPAddress(data, 0);
                defaultRouteReachability = new NetworkReachability(ip);
                defaultRouteReachability.SetNotification(OnChange);
                defaultRouteReachability.Schedule(CFRunLoop.Main, CFRunLoop.ModeDefault);
            }
            if (!defaultRouteReachability.TryGetFlags(out flags))
                return false;
            return IsReachableWithoutRequiringConnection(flags);
        }
开发者ID:charifield,项目名称:Xamarin.Plugins,代码行数:15,代码来源:Reachability.cs

示例11: IsAdHocWiFiNetworkAvailable

        /// <summary>
        /// Checks ad hoc wifi is available
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        public static bool IsAdHocWiFiNetworkAvailable(out NetworkReachabilityFlags flags)
        {
            if (adHocWiFiNetworkReachability == null)
            {
                //var ip = IPAddress.Parse("::ffff:169.254.0.0");
                var data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 169, 254, 0, 0 };
                var ip = new IPAddress(data, 0);
                adHocWiFiNetworkReachability = new NetworkReachability(ip);
                adHocWiFiNetworkReachability.SetNotification(OnChange);
                adHocWiFiNetworkReachability.Schedule(CFRunLoop.Main, CFRunLoop.ModeDefault);
            }

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

            return IsReachableWithoutRequiringConnection(flags);
        }
开发者ID:charifield,项目名称:Xamarin.Plugins,代码行数:22,代码来源:Reachability.cs

示例12: 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);
     }
     if (!defaultRouteReachability.TryGetFlags(out flags))
     {
         Application._networkstate = DataAccessLayer.NetworkState.Disconnected;
         if (Application._user != null) 
         Application._user.NetworkStatus = DataAccessLayer.NetworkState.Disconnected;
         return false;
     }
         
     return IsReachableWithoutRequiringConnection (flags);
 }   
开发者ID:MbProg,项目名称:MasterDetailTestProject-IOS-64,代码行数:17,代码来源:Reachability.cs

示例13: IsAdHocWiFiNetworkAvailable

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

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

            return IsReachableWithoutRequiringConnection(flags);
        }
开发者ID:rhellestrae,项目名称:XamFormsNetworkConnect,代码行数:15,代码来源:NetworkConnection.cs

示例14: IsNetworkAvailable

 //        private bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
 //        {
 //            if (defaultRouteReachability == null)
 //            {
 //                defaultRouteReachability = new NetworkReachability(new IPAddress(0));
 //                defaultRouteReachability.SetCallback(OnChange);
 //                defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
 //            }
 //            if (!defaultRouteReachability.TryGetFlags(out flags))
 //                return false;
 //            return IsReachableWithoutRequiringConnection(flags);
 //        }
 private bool IsNetworkAvailable(out NetworkReachabilityFlags flags)
 {
     if (defaultRouteReachability == null)
     {
         defaultRouteReachability = new NetworkReachability(new IPAddress(0));
         //SetCallback is depreciated
         //ORIG: defaultRouteReachability.SetCallback(OnChange);
         defaultRouteReachability.SetNotification(OnChange);
         defaultRouteReachability.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
     }
     if (!defaultRouteReachability.TryGetFlags(out flags))
         return false;
     return IsReachableWithoutRequiringConnection(flags);
 }
开发者ID:rhellestrae,项目名称:XamFormsNetworkConnect,代码行数:26,代码来源:NetworkConnection.cs

示例15: NetworkChangedListener

		public NetworkChangedListener ()
		{
			reachabilityChecker = new NetworkReachability (new IPAddress(0));
			reachabilityChecker.SetNotification (OnReachabilityChanged);
			reachabilityChecker.Schedule(CFRunLoop.Current, CFRunLoop.ModeDefault);
		}
开发者ID:alanmcgovern,项目名称:tunez,代码行数:6,代码来源:NetworkChangedListener.cs


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