本文整理汇总了C#中CubeFlag.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# CubeFlag.HasFlag方法的具体用法?C# CubeFlag.HasFlag怎么用?C# CubeFlag.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CubeFlag
的用法示例。
在下文中一共展示了CubeFlag.HasFlag方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FirstNotInvalidFlag
/// <summary>
/// Returns the first flag in the first parameter which the second parameter does not contain
/// </summary>
/// <param name="flags">Defines the posiible flags to be returned</param>
/// <param name="invalid">Defines the invalid flags</param>
/// <returns></returns>
public static CubeFlag FirstNotInvalidFlag(CubeFlag flags, CubeFlag invalid)
{
foreach (CubeFlag f in GetFlags(flags))
{
if (!invalid.HasFlag(f))
return f;
}
return CubeFlag.None;
}
示例2: ExceptFlag
/// <summary>
/// Returns a ClubFlag which contains all single flags in the first parameter which don't exist in the second parameter
/// </summary>
/// <param name="flags">Defines all possible flags</param>
/// <param name="invalid">Defines the flags to be filtered out of the first parameter</param>
/// <returns></returns>
public static CubeFlag ExceptFlag(CubeFlag flags, CubeFlag invalid)
{
CubeFlag pos = CubeFlag.None;
foreach (CubeFlag p in GetFlags(flags))
{
if (!invalid.HasFlag(p))
pos |= p;
}
return pos;
}
示例3: CommonFlags
/// <summary>
/// Returns a CubeFlag which contains all flags which exist in both the first and the second parameter
/// </summary>
/// <param name="first">Defines the first CubeFlag</param>
/// <param name="second">Defines the second CubeFlag</param>
/// <returns></returns>
public static CubeFlag CommonFlags(CubeFlag first, CubeFlag second)
{
CubeFlag commonFlags = CubeFlag.None;
foreach (CubeFlag flag in GetFlags(first))
{
if (second.HasFlag(flag))
commonFlags |= flag;
}
return commonFlags;
}
示例4: ToNotationString
/// <summary>
/// Converts the given CubeFlag into a notation string
/// </summary>
public static string ToNotationString(CubeFlag flag)
{
var notation = string.Empty;
if (flag.HasFlag(CubeFlag.TopLayer)) notation += "U";
if (flag.HasFlag(CubeFlag.BottomLayer)) notation += "D";
if (flag.HasFlag(CubeFlag.FrontSlice)) notation += "F";
if (flag.HasFlag(CubeFlag.RightSlice)) notation += "R";
if (flag.HasFlag(CubeFlag.BackSlice)) notation += "B";
if (flag.HasFlag(CubeFlag.LeftSlice)) notation += "L";
if (flag.HasFlag(CubeFlag.MiddleSlice)) notation += "S";
if (flag.HasFlag(CubeFlag.MiddleSliceSides)) notation += "M";
if (flag.HasFlag(CubeFlag.MiddleLayer)) notation += "E";
return notation;
}
示例5: CommonFlags
/// <summary>
/// Returns a CubeFlag which contains all flags which exist in both the first and the second parameter
/// </summary>
/// <param name="first">Defines the first CubeFlag</param>
/// <param name="second">Defines the second CubeFlag</param>
/// <returns></returns>
public static CubeFlag CommonFlags(CubeFlag first, CubeFlag second) => GetFlags(first).Cast<CubeFlag>().Where(flag => second.HasFlag(flag)).Aggregate(CubeFlag.None, (current, flag) => current | flag);
示例6: ExceptFlag
/// <summary>
/// Returns a ClubFlag which contains all single flags in the first parameter which don't exist in the second parameter
/// </summary>
/// <param name="flags">Defines all possible flags</param>
/// <param name="invalid">Defines the flags to be filtered out of the first parameter</param>
/// <returns></returns>
public static CubeFlag ExceptFlag(CubeFlag flags, CubeFlag invalid) => (from CubeFlag p in GetFlags(flags) where !invalid.HasFlag(p) select p).Aggregate(CubeFlag.None, (current, p) => current | p);
示例7: FirstNotInvalidFlag
/// <summary>
/// Returns the first flag in the first parameter which the second parameter does not contain
/// </summary>
/// <param name="flags">Defines the posiible flags to be returned</param>
/// <param name="invalid">Defines the invalid flags</param>
/// <returns></returns>
public static CubeFlag FirstNotInvalidFlag(CubeFlag flags, CubeFlag invalid) => GetFlags(flags).Cast<CubeFlag>().FirstOrDefault(f => !invalid.HasFlag(f));
示例8: GetFlags
/// <summary>
/// Yields each single flag within the parameter
/// </summary>
/// <param name="flags">Defines the flag to be 'splitted'</param>
/// <returns></returns>
public static IEnumerable<Enum> GetFlags(CubeFlag flags)
{
foreach (Enum value in Enum.GetValues(flags.GetType()))
{
if (flags.HasFlag(value))
yield return value;
}
}