How to pass array of simple types into In-Rule method

355 Views Asked by At

I have In Rule method that should accept set of simple types e.g. array of string type or array of integers (int16).

I tried to create following methods

/* Method with string array*/
[Method(DisplayName = "[M1]")]
    public int Method1([Parameter(ValueInputType.All)] 
                        string[] valStrings )
    {
        return valStrings.Length; // any calculation goes here
    }
}

/* Method with PARAMS string array*/
[Method(DisplayName = "[M2]")]
    public int Method2([Parameter(ValueInputType.All)] 
                       params string[] valStrings )
    {
        return valStrings.Length; // any calculation goes here
    }
}

/* Method with INT ARRAY referencing on external data source*/
[Method(DisplayName = "[M2]")]
    public int Method2([Parameter(ValueInputType.All,
                        DataSourceName="myDataList" )] 
                       params int[] valInt )
    {
        return valInt; // any calculation goes here
    }
}

It seems that codeeffect library 4.3.2.6 does not support passing user entered parameters into the In-Rule method and restricts In-Rule method with only simple parameter type e.g. Int but not int[] . Seems that I cannot connect DataSource with In Rule method to pass more than one item from data source into the in-rule method. The main idea that only USER should enter either the simple type(s) or select more than one data source item? I cannot restrict user to pass Source Object Field from source object that returns collection.

Any suggestions or workarounds?

1

There are 1 best solutions below

1
On

CodeEffects supports in-rule methods that take fields of IEnumerable types as params. In-rule methods can also return IEnumerable collections, including arrays. It cannot take arrays as params, though, due to certain limitations in .NET reflection. Code Effects also doesn't support user input of any kind of arrays in general simply because that would be a UI nightmare for devs and end users. More info is available here and here

You can use Dynamic Menu Data Sources to bring data from your database to be used as values or as params. Details can be found here