/// <summary> /// This code gets called on the first time this Object type is constructed /// </summary> void AddSharedBusinessRules() { lock (_LockObject) { if (!(SharedValidationRules.RulesExistFor(this.GetType()))) { ValidationRulesManager mgrValidation = SharedValidationRules.GetManager(this.GetType()); CharacterCasingRulesManager mgrCharacterCasing = SharedCharacterCasingRules.GetManager(this.GetType()); foreach (PropertyInfo prop in this.GetType().GetProperties()) { foreach (BaseValidatorAttribute atr in prop.GetCustomAttributes(typeof(BaseValidatorAttribute), false)) { mgrValidation.AddRule(atr.Create(prop.Name), prop.Name); } foreach (CharacterCasingFormattingAttribute atr in prop.GetCustomAttributes(typeof(CharacterCasingFormattingAttribute), false)) { mgrCharacterCasing.AddRule(prop.Name, atr.CharacterCasing); } } AddSharedBusinessValidationRules(mgrValidation); AddSharedCharacterCasingFormattingRules(mgrCharacterCasing); } } }
/// <summary> /// Override this method in your business class to be notified when you need to set up SHARED character casing rules. This method is only used by the sub-class and not consumers of the sub-class. /// To add shared character case formatting to deriving class properties, override this method in deriving classes and add the rules to the CharacterCasingRulesManager. /// This method will only be called once; the first time the deriving class is created. /// </summary> protected void AddSharedCharacterCasingFormattingRules(CharacterCasingRulesManager mgrCharacterCasing) { }