/// <summary> /// If O is a validatingSerializer, calls its validate method with the property name, /// otherwise, checks for any ValidatorAttribute attributes and processes them. /// </summary> private void Validate(object O, MemberInfo M) { if (typeof(IValidatingSerializer).IsInstanceOfType(O)) { ((IValidatingSerializer)O).Validate(this, M.Name); } else { IVS.Validate(this, M, new ValidatingSerializerEventArgs(this, O, M.Name)); } }
/// <summary> /// Recursively calls Validate on all the items in the list /// and appends their Errors to this. Should be overriden in derived classes /// to perform any specific Validator required for the list. /// </summary> public virtual void Validate() { if (SkipValidation) { return; } IVS.Validate(this, this.GetType(), new ValidatingSerializerEventArgs(this)); int n = 0; foreach (ValidatingSerializer S in this) { S.Validate(this, "[" + n + "]"); n++; } }
/// <summary> /// Recursively calls Validate on any IValidatingSerializer properties, /// and appends their Errors to this. Should be overriden in derived classes /// to perform specific Validator on any other properties. /// </summary> public virtual void Validate() { if (SkipValidation) { return; } Type T = this.GetType(); IVS.Validate(this, T, new ValidatingSerializerEventArgs(this)); foreach (PropertyInfo P in T.GetProperties()) { if (P.Name != "Item") { Validate(P.GetValue(this, new object[] {}), P); } } foreach (FieldInfo F in T.GetFields()) { Validate(F.GetValue(this), F); } }
/// <summary>Calls basic Validator and bubbles errors up to V.</summary> public void Validate(IValidatingSerializer V, string PropertyName) { IVS.Validate(this, V, PropertyName); }