I've noticed in the Ebook that Rocky does not check if InputProperties=null, for example:
public class ValidPrefix : Csla.Rules.BusinessRule
{
public string Prefix { get; private set; }
public ValidPrefix(Csla.Core.IPropertyInfo primaryProperty, string prefix)
: base(primaryProperty)
{
InputProperties = new List<Csla.Core.IPropertyInfo> { PrimaryProperty }; //<--NO CHECK IF NULL
However when trying to research something on the forums here I noticed Jonny and others consistently do this:
if (InputProperties == null) InputProperties = new List<IPropertyInfo>();
My question is which way should it be done?
Hi,
When you start to subclass rules you will prefer to use the latter one and keep a consistent programming model so that you do not destroy InputProperties from the base rule.
If you never subclass a rule the first one will also work fine.
I am however going to change the programming model a bit for CSLA 4.5 - so that InputProperties and AffectedProperties are always treated the same and immediately get an instance. I do not fancy having to always make sure that InputProperties have an instance (no instance created by default) and AffectedProperties always have an instance. And this fails at runtime with a NullReferenceException - not in the compiler.
Thank you Jonny!
Copyright (c) Marimer LLC