In the Csla.Rules.BusinessRule instance constructor the InputProperties is initialized:
protected BusinessRule(Csla.Core.IPropertyInfo primaryProperty)
{
...
InputProperties = new List<Core.IPropertyInfo>();
...
}
Why do all examples in the CSLA4 book and all the common Common Rules are re-initializing the InputProperties? Ex:
public MinValue(Csla.Core.IPropertyInfo primaryProperty, T min) : base(primaryProperty)
{
...
InputProperties = new List<Core.IPropertyInfo> { primaryProperty };
}
Is it more efficient than just adding a new Property to the list?
public MinValue(Csla.Core.IPropertyInfo primaryProperty, T min) : base(primaryProperty)
{
...
InputProperties.Add(primaryProperty);
}
Thanks.
That is because InputProprties is null (ie: not set to an instance if the list in class constructor).
But the BusinessRule base class always initializes the InputProperties property in the constructor
protected BusinessRule()
: this(null)
{ }
/// <summary>
/// Creates an instance of the rule that applies
/// to a specfic property.
/// </summary>
/// <param name="primaryProperty">Primary property for this rule.</param>
protected BusinessRule(Csla.Core.IPropertyInfo primaryProperty)
{
AffectedProperties = new List<Core.IPropertyInfo>();
InputProperties = new List<Core.IPropertyInfo>();
PrimaryProperty = primaryProperty;
this.RuleUri = new RuleUri(this, primaryProperty);
RunMode = RunModes.Default;
}
Hi,
Wasn't always like this. This is the code from Csla.4.0 and at least up until 4.3.13:
protected BusinessRule(Csla.Core.IPropertyInfo primaryProperty)
{
AffectedProperties = new List<Core.IPropertyInfo>();
PrimaryProperty = primaryProperty;
this.RuleUri = new RuleUri(this, primaryProperty);
RunMode = RunModes.Default;
}
The samples code may not be entirely up to date for Csla 4.5 release yet.
Copyright (c) Marimer LLC