//Generic<FanXing> gFanXing = new Generic<FanXing>(); //Generic<Base> gFanXingBase = new Generic<Base>(); //Generic<string> gs = new Generic<string>(); 这样定义会报错 public static void Excute() { GenericFunc gf = new GenericFunc(); gf.FanXingFunc <FanXing>(new FanXing() { Name = "Kiba518" }); }
public EmployeeInformation Search(string name) { var result = GenericFunc.regexChecker(name); if (result != null) { return(_eManager.Search(result)); } else { throw new Exception("please enter valid name"); } }
private static TreeNode ParseMathConstant(GenericFunc constant) { return(new TreeNode { Func = constant, arguments = new TreeNode[0] }); }
private static TreeNode ParseFunctionCall(string text, string funcName, IList <string> realVariableNames, IList <string> intVariableNames, ref string errMsg) { if (!text.StartsWith(funcName)) { errMsg = "Cannot parse as function: " + text; return(null); } string argStr = text.Substring(funcName.Length + 1, text.Length - funcName.Length - 2); if (argStr.Length == 0) { errMsg = "Empty argument for " + funcName; return(null); } string[] args = argStr.Split(','); int numArgs = args.Length; List <GenericFunc> funcs = GenericFunc.funcMap[funcName]; GenericFunc func = GetSuitableFunc(funcs, numArgs); if (func == null) { errMsg = "Could not find suitable function: " + funcName; } if (func is Func1) { Func1 func1 = (Func1)func; TreeNode result = new TreeNode { Func = func1, arguments = new TreeNode[1] }; result.arguments[0] = ParseImpl(args[0], realVariableNames, intVariableNames, ref errMsg); return(errMsg == null ? result : null); } if (func is Func2) { Func2 func2 = (Func2)func; TreeNode result = new TreeNode { Func = func2, arguments = new TreeNode[2] }; result.arguments[0] = ParseImpl(args[0], realVariableNames, intVariableNames, ref errMsg); result.arguments[1] = ParseImpl(args[1], realVariableNames, intVariableNames, ref errMsg); return(errMsg == null ? result : null); } if (func is FuncN) { FuncN funcN = (FuncN)func; TreeNode result = new TreeNode { Func = funcN, arguments = new TreeNode[args.Length] }; for (int i = 0; i < args.Length; i++) { result.arguments[i] = ParseImpl(args[i], realVariableNames, intVariableNames, ref errMsg); if (errMsg != null) { return(null); } } return(result); } throw new Exception("Never get here."); }
public Eqhelper() { _htmlHelper = new GenericFunc(); _excelHelper = new ExcelHelper(); }