Thanks for this library, it's wonderfully straightforward!
Now, my problem - consider a class and hierarchy like this:
public class Order
{
public IList<IItem> Items { get; set; }
}
public interface IItem
{
Guid Id { get; set; }
}
public class StandardItem : IItem
{
...
}
public class SpecialItem : IItem
{
public string Name { get; set; }
}
What I'd like to do is create a Rule that can match on the Items collection for a specific type of IItem, for example to match only on SpecialItem instances:
var rule = Rule.Any(nameof(Order.Items), Rule.Create(nameof(SpecialItem.Name), MreOperator.Equal, "My Special Item Name"));
The above doesn't work, because:
MicroRuleEngine.RulesException: Cannot find property Name in class IItem ("Name")
I guess what's really needed here is some way to "pre-filter" the collection with Linq's .OfType<SpecialItem>(). Is something like this possible already? Otherwise, are you able to offer a few pointers about the best way to add this functionality? (happy to submit a PR)
Thanks for this library, it's wonderfully straightforward!
Now, my problem - consider a class and hierarchy like this:
What I'd like to do is create a
Rule
that can match on theItems
collection for a specific type ofIItem
, for example to match only onSpecialItem
instances:The above doesn't work, because:
I guess what's really needed here is some way to "pre-filter" the collection with Linq's
.OfType<SpecialItem>()
. Is something like this possible already? Otherwise, are you able to offer a few pointers about the best way to add this functionality? (happy to submit a PR)