//-------------------------------------------------------------------- /// <summary> /// Invokes a method in the LogicLayer.Reports class and returns /// the result from that method as datasource for the report. /// </summary> /// <param name="methodName"></param> /// <param name="parameters"></param> /// <returns></returns> //-------------------------------------------------------------------- public static object InvokeMethod(string methodName, params Parameter[] parameters) { // construct the parameters Hashtable // ReportParameters reportParameters = new ReportParameters(); if (parameters != null) { foreach (Parameter parameter in parameters) { if (parameter.IsSingleValue) { if (parameter.Value == DBNull.Value) reportParameters.AddParameter(parameter.ParameterName, null); else reportParameters.AddParameter(parameter.ParameterName, parameter.Value); } else reportParameters.AddParameter(parameter.ParameterName, parameter.List); } } // get the method pointer and invoke the method immediately. // Type t = typeof(LogicLayer.Reports); MethodInfo mi = t.GetMethod(methodName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); if (mi != null) return mi.Invoke(null, new object[] { reportParameters }); else throw new Exception("Unable to invoke method '" + methodName + "' to generate the report."); }