本文整理汇总了C#中NetworkReachabilityFlags类的典型用法代码示例。如果您正苦于以下问题:C# NetworkReachabilityFlags类的具体用法?C# NetworkReachabilityFlags怎么用?C# NetworkReachabilityFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkReachabilityFlags类属于命名空间,在下文中一共展示了NetworkReachabilityFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: HandleCallback
static void HandleCallback (IntPtr reachability, NetworkReachabilityFlags flags, IntPtr info)
{
if (info == IntPtr.Zero)
return;
var instance = GCHandle.FromIntPtr (info).Target as MacNetworkChange;
if (instance == null || instance.flags == flags)
return;
instance.flags = flags;
var addressChanged = instance.networkAddressChanged;
if (addressChanged != null)
addressChanged (null, EventArgs.Empty);
var availabilityChanged = instance.networkAvailabilityChanged;
if (availabilityChanged != null)
availabilityChanged (null, new NetworkAvailabilityEventArgs (instance.IsAvailable));
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:19,代码来源:NetworkChange.cs
示例17: Dispose
public void Dispose ()
{
lock (this) {
if (handle == IntPtr.Zero)
return;
if (scheduledWithRunLoop)
SCNetworkReachabilityUnscheduleFromRunLoop (handle, CFRunLoopGetMain (), runLoopMode);
CFRelease (handle);
handle = IntPtr.Zero;
callback = null;
flags = NetworkReachabilityFlags.None;
scheduledWithRunLoop = false;
}
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:16,代码来源:NetworkChange.cs
示例18: SCNetworkReachabilityGetFlags
static extern bool SCNetworkReachabilityGetFlags (IntPtr reachability, out NetworkReachabilityFlags flags);
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:1,代码来源:NetworkChange.cs
示例19: ReachabilityChanged
//
// Invoked on the main loop when reachability changes
//
void ReachabilityChanged(NetworkReachabilityFlags flags)
{
}
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:6,代码来源:main.cs
示例20: IsNetworkAvaialable
/// <summary>
///
/// </summary>
/// <param name="flags">
/// A <see cref="NetworkReachabilityFlags"/>
/// </param>
/// <returns>
/// A <see cref="System.Boolean"/>
/// </returns>
private static bool IsNetworkAvaialable(out NetworkReachabilityFlags flags)
{
NetworkReachability defaultRouteReachability = new NetworkReachability (new IPAddress (0));
if (defaultRouteReachability.TryGetFlags (out flags))
return false;
return IsReachable (flags) && IsNoConnectionRequired(flags); // is reachable without requiring connection.
}
开发者ID:jioe,项目名称:appverse-mobile,代码行数:17,代码来源:IPhoneNet.cs
注:本文中的NetworkReachabilityFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论