Open africaninternetgroup opened 5 years ago
You must remember that AddBusinessRules is only called once-per-type and then cached. This method is not called every time an object of that type is created.
You could create an object level rule and then call an "external" validator to do all validation of the BO similar to what f.ex FluentValidator or NRule engine does. You would lose the flexibility of the built-in rule engine rerunning rules for affected properties tho' and triggering the execution of rules would have to be overridden in your code.
@jonnybee , slightly off the topic but
You must remember that AddBusinessRules is only called once-per-type and then cached. This method is not called every time an object of that type is created.
how is it cached? i mean the caching mechanism?
kind regards
They are cached in static threadsafe collections.
Thank you @rockfordlhotka
Thanks @jonnybee ,so are you implying that to run such object rules I have to override the PropertyHasChanged for the object rules to run when the user changes the BO Properties?Secondly we are not familiar with the FluentValidator or NRule how are these able to "inject Tenant rules for a Specific BO.Do they somehow support Dependency Injection?
None of these validation/Business rules engines are able to inject tenant rules for a specific BO as far as I know. You will have to create a mechanism of detecting which Validator or Rules to call, whether you create CSLA.NET rules in a dynamic assembly or use an external rule/validation engine.
We are developing a Multi Tenant ASP.NET Core MVC application using CSLA.NET.We are thinking of letting Users (Tenants) to be able to define their own business rules by using either a DSL or using wizard pages by answering a series of questions and generate business rule code using Rosyln.We are aware CSLA.NET provides a concept of RuleSets.Our Challenge is how to call these Tenant Specific Business Rules in the AddBusinessRules Override of the BO.
Version and Platform CSLA version: 4.7.100 OS: Windows, Linux, iOS, Android, etc. Platform: WinForms, WPF, ASP.NET Core, MVC, Xamarin, etc.