public object[,] Eval(params object[] inputs) { try { var convertedInputs = new List <object>(); for (var i = 0; i < inputs.Length - _argOffset; i++) { var paramName = _methodInfo.GetParameters()[i].Name; var inputAsMatrix = inputs[i + _argOffset] as object[, ]; if (inputAsMatrix[0, 0] is ExcelMissing && _defaultValues[i] == string.Empty) { throw new ArgumentException($"{paramName}: Is left blank but is not optional."); } convertedInputs.Add(ExcelTypeConverter.ConvertInput(_methodInfo.GetParameters()[i].ParameterType, inputAsMatrix, paramName, _defaultValues[i])); } var output = _methodInfo.Invoke(null, convertedInputs.ToArray()); var outputName = _argOffset == 0 ? null : GetOutputName(inputs[0]); return(ExcelTypeConverter.ConvertOuput(_methodInfo.ReturnType, output, outputName)); } catch (TargetInvocationException e) { var result = new object[1, 1]; if (e.InnerException != null) { result[0, 0] = "ERROR: " + e.InnerException.Message; } else { result[0, 0] = "ERROR: " + e.Message; } return(result); } catch (Exception e) { var result = new object[1, 1]; result[0, 0] = "ERROR: " + e.Message; return(result); } }
public static object[,] ViewObjectPropertyValue( [QuantSAExcelArgument(Description = "The object you wish to view.", Name = "Object")] object objectName, [QuantSAExcelArgument(Description = "The name of the property from the object that you wish to view.")] string propertyName, [QuantSAExcelArgument(Description = "If the property with propertyName is in turn an object then this" + "is the name of the property inside that which you wish to view.", Default = null)] string propertyNameL2) { if (propertyNameL2 != null) { var obj = GetObjectPropertyValue(objectName, propertyName); return(ViewObjectPropertyValue(obj, propertyNameL2, null)); } var output = GetObjectPropertyValue(objectName, propertyName); if (output is ISerializableViaName objWithName) { return(ExcelTypeConverter.ConvertOuput(typeof(string), objWithName.GetName(), propertyName)); } return(ExcelTypeConverter.ConvertOuput(output.GetType(), output, propertyName)); }