BusinessRule primary property as IPropertyInfo or PropertyInfo<> #3693
-
In every sample I see, properties are sent to the business rules as IPropertyInfo. Is there a reason to NOT create business rules with a constructor parameter of PropertyInfo<> instead? For example, I have a rule that expects the primary property to be a string. I can enforce this at the caller by using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You are free to design the constructors on your rule classes as best fits your needs. PrimaryProperty of the rule class is type IPropertyInfo. As long as the type used on the constructor parameter implements IPropertyInfo, you can assign it to PrimaryProperty. Within the Execute method, references to PrimaryProperty would still need to be cast. You could keep a secondary private variable of the PropertyInfo type to avoid using PrimaryProperty. |
Beta Was this translation helpful? Give feedback.
You are free to design the constructors on your rule classes as best fits your needs. PrimaryProperty of the rule class is type IPropertyInfo. As long as the type used on the constructor parameter implements IPropertyInfo, you can assign it to PrimaryProperty.
Within the Execute method, references to PrimaryProperty would still need to be cast. You could keep a secondary private variable of the PropertyInfo type to avoid using PrimaryProperty.