Code: Select all
public class ExecutionUtility
{
public static TIn2 ExecutionHelper(Func function, TIn1 input)
{
TIn2 output = default(TIn2);
int result = function(input, out output); // the out keyworkd is not accepted apparently
if (result == 0)
{
return output;
}
else
{
throw new FunctionExecutionException(result);
}
}
}
Code: Select all
public class FunctionExecutionException : Exception
{
public int ErrorCode { get; }
public FunctionExecutionException(int errorCode)
: base($"Function execution failed with error code: {errorCode}")
{
ErrorCode = errorCode;
}
}
Code: Select all
public static int myfunction(int input, out string output)
{
if (input > 0)
{
output = "OUTPUT_VALUE_1";
return 0;
}
else
{
output = "OUTPUT_VALUE_2";
return -1;
}
}
Code: Select all
return ExecutionUtility.API_VERIFY(PRD_GCAPI.myfunction, this.Index);