public virtual void EnumElements(EnumElementHandler Handler, ElementType Type, EnumFlag Flag, string NameOfElement, object Param) { }
static void PrintAllMissesDay(EnumFlag e) { foreach (var v in Enum.GetNames(typeof(EnumFlag))) { if (Enum.TryParse <EnumFlag>(v, out EnumFlag result) != e.HasFlag(result)) { Console.WriteLine(result); } } }
public void EnumElements(EnumElementHandler Handler, ElementType Type, EnumFlag Flag, string NameOfElement, object Param) { Debug.Assert(null != m_iHostService); m_iHostService.EnumElements(Handler, Type, Flag, NameOfElement, Param); }
static bool ThisDayExist(EnumFlag myEnum, EnumFlag day) { if (myEnum.HasFlag(day)) { return(true); } else { return(false); } }
static void Main(string[] args) { EnumFlag days = new EnumFlag(); days = EnumFlag.Sunday | EnumFlag.Wednesday; Console.WriteLine(days); ThisDayExist(days, EnumFlag.Wednesday); ThisDayExist(days, EnumFlag.Friday); PrintAllMissesDay(days); days = AddDay(days, EnumFlag.Monday); days = RemoveDay(days, EnumFlag.Wednesday); PrintAllMissesDay(days); }
public void SetFlagSumTest() { var enumFlag = new EnumFlag <TestFlag>(); enumFlag.SetFlagSum(5); Assert.IsFalse(enumFlag.Test(TestFlag.None)); Assert.IsTrue(enumFlag.Test(TestFlag.Value1)); Assert.IsFalse(enumFlag.Test(TestFlag.Value2)); Assert.IsTrue(enumFlag.Test(TestFlag.Value3)); Assert.IsFalse(enumFlag.Test(TestFlag.Value4)); Assert.IsFalse(enumFlag.Test(TestFlag.Value5)); enumFlag.SetFlagSum(7); Assert.IsFalse(enumFlag.Test(TestFlag.None)); Assert.IsTrue(enumFlag.Test(TestFlag.Value1)); Assert.IsTrue(enumFlag.Test(TestFlag.Value2)); Assert.IsTrue(enumFlag.Test(TestFlag.Value3)); Assert.IsFalse(enumFlag.Test(TestFlag.Value4)); Assert.IsFalse(enumFlag.Test(TestFlag.Value5)); enumFlag.Accept(TestFlag.Value5); Assert.AreEqual(23, enumFlag.ToBitMask()); }
static EnumFlag RemoveDay(EnumFlag myEnum, EnumFlag day) { return(myEnum &= ~day); }
static EnumFlag AddDay(EnumFlag myEnum, EnumFlag day) { return(myEnum | day); }
public void EnumElement(EnumElementHandler Handler, ElementType Type, EnumFlag Flag, string NameOfElement, object Param) { Debug.Assert(null != Handler); //name Regex reg = null; if (!string.IsNullOrEmpty(NameOfElement)) { reg = new Regex(NameOfElement, RegexOptions.IgnoreCase); } bool continueEnum = true; foreach (var ele in m_dicScreenElements) { if ((ElementType.Button == Type) && !(ele.Value is HtmlScreenButtonElement)) { continue; } if ((ElementType.Input == Type) && !(ele.Value is HtmlScreenInputElement)) { continue; } if (EnumFlag.OnlyEnable == Flag && !(ele.Value.IsEnable)) { continue; } if (EnumFlag.OnlyVisible == Flag && !(ele.Value.IsVisible)) { continue; } if (EnumFlag.VisibleAndEnable == Flag && !(ele.Value.IsVisible && ele.Value.IsEnable)) { continue; } if (EnumFlag.VisibleOrEnable == Flag && (!ele.Value.IsEnable && !ele.Value.IsVisible)) { continue; } if (null != reg) { Match m = reg.Match(ele.Value.HostedElement.Id); if (!m.Success) { continue; } } continueEnum = Handler.Invoke(ele.Value.HostedElement.Id, ele.Value.Key, Param); if (!continueEnum) { break; } } }