46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using System;
|
|
|
|
namespace FileInterface.Scheduler
|
|
{
|
|
public sealed class CustomFunctionCallResult
|
|
{
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; }
|
|
|
|
public static CustomFunctionCallResult Ok(string message)
|
|
{
|
|
return new CustomFunctionCallResult { Success = true, Message = message ?? "OK" };
|
|
}
|
|
|
|
public static CustomFunctionCallResult Fail(string message)
|
|
{
|
|
return new CustomFunctionCallResult { Success = false, Message = message ?? "CustomFunction failed" };
|
|
}
|
|
}
|
|
|
|
public interface ICustomFunctionInvoker
|
|
{
|
|
CustomFunctionCallResult Invoke(string customFunctionName, string[] inArgs);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lets the existing FileInterface IMS code remain untouched. Wire the current
|
|
/// IMS CustomFunction call into this delegate in Program.cs / service startup.
|
|
/// </summary>
|
|
public sealed class DelegateCustomFunctionInvoker : ICustomFunctionInvoker
|
|
{
|
|
private readonly Func<string, string[], CustomFunctionCallResult> _handler;
|
|
|
|
public DelegateCustomFunctionInvoker(Func<string, string[], CustomFunctionCallResult> handler)
|
|
{
|
|
if (handler == null) throw new ArgumentNullException("handler");
|
|
_handler = handler;
|
|
}
|
|
|
|
public CustomFunctionCallResult Invoke(string customFunctionName, string[] inArgs)
|
|
{
|
|
return _handler(customFunctionName, inArgs);
|
|
}
|
|
}
|
|
}
|