本文整理匯總了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;
}