private FunctionDescr Scan() { if (_info == null) { var info = new FunctionDescr(); var t = this.GetType(); var suffix = "Function"; info.name = t.Name.Substring(0, t.Name.Length - suffix.Length); MethodInfo m = t.GetMethod("Execute", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (m == null) { throw new InvalidOperationException($"Missing Execute method"); } info.retType = GetType(m.ReturnType); info.paramTypes = Array.ConvertAll(m.GetParameters(), p => GetType(p.ParameterType)); info._method = m; _info = info; } return(_info); }
// Explicitly provide types. // Necessary for Tables/Records protected ReflectionFunction(string name, FormulaType returnType, params FormulaType[] paramTypes) { var t = this.GetType(); MethodInfo m = t.GetMethod("Execute", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (m == null) { throw new InvalidOperationException($"Missing Execute method"); } _info = new FunctionDescr { name = name, retType = returnType, paramTypes = paramTypes, _method = m }; }
/// <summary> /// Assume by defaults. Will reflect to get primitive types /// </summary> protected ReflectionFunction() { _info = null; }