I have created my own int array TypeConverter
(which is working just fine with Convert.ChangeType()
), but it does not work with Hangfire when used as method parameter attribute:
...
int[] intarray = new int[] { 1, 2, 3, 4 };
Hangfire.BackgroundJob.Enqueue(() => TestJobIntArray(intarray));
...
...
public static void TestJobIntArray([TypeConverter(typeof(IntArrayConverter))] int[] intarray) {
foreach (var i in intarray) {
Console.WriteLine(i);
}
}
And I think it should.
The only workaround I have found is create my own class derived from List<int>
, and apply TypeConverterAttribute
to this class. But that is very impractical solution. Am I doing something wrong, or method parameter attributes are not supported by Hangfire ?
PS: I have tried adding TypeConverterAttribute
to a class property, but that didn’t work neither.