We've coded up a bunch of script API methods which work great, but we've come across an issue with one that we wanted to use a bunch of options with, just like you do in the core script APIs. An example of one of yours is;

So this accepts a bunch of named parameters via that object, and not all need to be supplied.
When we code up something similar the method never gets called.. here's some example code;
namespace Example.StuffAPI
{
[Documentation(Category = "Blah")]
public class UtilsAPI: IApi
{
public string GetStuff(StuffOptions options)
{
return options.Thingy + options.Foo;
}
public class StuffOptions
{
public string Thingy { get; set; }
public string Foo { get; set; }
}
}
}
When we call it from Velocity it only re-outputs the method name, indicating it can't find a matching signature for the method + parameters.
$stuff.GetStuff("%{ Thingy='hello', Foo='world' }")
#set($options = "%{}")
$options.Add("Thingy", "hello")
$options.Add("Foo", "world")
$stuff.GetStuff($options)
If we switch out the C# method to use IDictionary instead it is called correctly..
namespace Example.StuffAPI
{
[Documentation(Category = "Blah")]
public class UtilsAPI: IApi
{
public string GetStuff(IDictionary options)
{
return options["Thingy"] + options["Foo"];
}
}
}
The Velocity remains the same & now works.
We can obviously work with IDictionary, but I'm wondering why the first approach doesn't work & if we're missing something?