Пример #1
0
 private void ActionTypeBind()
 {
     cblActionType.Items.Clear();
     foreach (EnumInfo kvp in EnumInfo.AnalysisList <Tools.Const.Enums.ManagementOperate>())
     {
         cblActionType.Items.Add(new ListItem(kvp.Explain + "(" + kvp.Name + ")", kvp.Name));
     }
 }
Пример #2
0
        public CaseModel Func_AnalysisList()
        {
            return(new CaseModel()
            {
                NameSign = @"解析枚举的所有选项",
                ExeEvent = () => {
                    EnumInfo[] answer = new EnumInfo[] {
                        new EnumInfo()
                        {
                            Name = @"Secrecy", IntValue = 0, Explain = @"保密"
                        },
                        new EnumInfo()
                        {
                            Name = @"Male", IntValue = 1, Explain = ExplainAttribute.ERROR_EXPLAIN_TEXT
                        },
                        new EnumInfo()
                        {
                            Name = @"Female", IntValue = 81, Explain = @"女"
                        },
                        new EnumInfo()
                        {
                            Name = @"Test", IntValue = 82, Explain = ExplainAttribute.ERROR_EXPLAIN_TEXT
                        },
                    };

                    EnumInfo[] enums = EnumInfo.AnalysisList <TestEnum>();
                    foreach (EnumInfo ci in enums)
                    {
                        bool is_did_find = false;
                        foreach (EnumInfo ai in answer)
                        {
                            if (ci.Name.Equals(ai.Name))
                            {
                                is_did_find = true;
                                if (!ci.IntValue.Equals(ai.IntValue))
                                {
                                    return false;
                                }
                                if (!ci.Explain.Equals(ai.Explain))
                                {
                                    return false;
                                }
                            }
                        }
                        if (!is_did_find)
                        {
                            return false;
                        }
                    }
                    return true;
                },
            });
        }