简单工厂模式
class Operate { public string _firstKey; public string _secondKey; public string _extendKey; public string FirstKey { get { return _firstKey;} set{_firstKey=value;} } public string SecondKey { get { return _secondKey; } set { _secondKey = value; } } public string ExtendKey { get { return _extendKey; } set { _extendKey = value; } } public virtual string GetCheckValue() { string _checkValue = "0"; return _checkValue; } } class OperateOne : Operate { public override string GetCheckValue() { MethodsCheck c=new MethodsCheck(); string _checkValue = c.fileExistCheck(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateTwo : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.RegMachineCheck(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateThree : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.passwordValidate(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateFour : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetDriverVersion(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateFive : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.Getfilelength(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateSix : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetNetCardName(SecondKey).ToString(); return _checkValue; } } class OperateSeven : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetnetConfig(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateEight : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.RegUserCheck(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateNine : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetTxTstring(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateTen : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetXMLString(FirstKey, SecondKey).ToString(); return _checkValue; } } class OperateEleven : Operate { public override string GetCheckValue() { MethodsCheck c = new MethodsCheck(); string _checkValue = c.GetStringLinq(FirstKey, SecondKey,ExtendKey).ToString(); return _checkValue; } } class OperateFactory { public static Operate CreateOperate(string chkId) { Operate oper = null; switch (chkId) { case "1": { oper = new OperateOne(); break; } case "2": { oper = new OperateTwo(); break; } case "3": { oper = new OperateThree(); break; } case "4": { oper = new OperateFour(); break; } case "5": { oper = new OperateFive(); break; } case "6": { oper = new OperateSix(); break; } case "7": { oper = new OperateSeven(); break; } case "8": { oper = new OperateEight(); break; } case "9": { oper = new OperateNine(); break; } case "10": { oper = new OperateTen(); break; } case "11": { oper = new OperateEleven(); break; } } return oper; } }