本文整理汇总了C#中AccessType.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# AccessType.HasFlag方法的具体用法?C# AccessType.HasFlag怎么用?C# AccessType.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AccessType
的用法示例。
在下文中一共展示了AccessType.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAccessible
/// <summary>
/// Determines if the server is accessible through the selected networks
/// </summary>
/// <param name="access">The access scheme</param>
/// <returns>True if the server was accessible through all the specified access networks</returns>
public async Task<bool> IsAccessible(AccessType access)
{
bool accessFailed = false;
if (access.HasFlag(AccessType.Internet))
{
Logging.OnLogMessage("Checking access from the internet", MessageType.Info);
if (await ServerIsListening(Settings.Instance.Internet, Settings.Instance.Port))
Logging.OnLogMessage("Access is possible through the internet", MessageType.Info);
else
accessFailed = true;
}
if (access.HasFlag(AccessType.LAN))
{
Logging.OnLogMessage("Checking access from the local network", MessageType.Info);
if (await ServerIsListening(Settings.Instance.LAN, Settings.Instance.Port))
Logging.OnLogMessage("Access is possible through the local network", MessageType.Info);
else
accessFailed = true;
}
if (access.HasFlag(AccessType.Loopback))
{
Logging.OnLogMessage("Checking access via loopback", MessageType.Info);
if (await ServerIsListening(Settings.Instance.Loopback, Settings.Instance.Port))
Logging.OnLogMessage("Access is possible through loopback", MessageType.Info);
else
accessFailed = true;
}
return !accessFailed;
}