private void VisitProperties(ModelMetadata metadata, VisitContext visitContext) { Contract.Requires(metadata != null); Contract.Requires(visitContext != null); PropertyScope propertyScope = new PropertyScope(); visitContext.KeyBuilders.Push(propertyScope); foreach (ModelMetadata childMetadata in metadata.Properties) { propertyScope.PropertyName = childMetadata.PropertyName; this.VisitNodeAndChildren(childMetadata, visitContext); } visitContext.KeyBuilders.Pop(); }
private bool ValidateProperties(ModelMetadata metadata, ValidationContext validationContext) { Contract.Requires(validationContext != null); Contract.Requires(metadata != null); bool isValid = true; PropertyScope propertyScope = new PropertyScope(); validationContext.KeyBuilders.Push(propertyScope); foreach (ModelMetadata childMetadata in validationContext.MetadataProvider.GetMetadataForProperties(metadata.Model, metadata.RealModelType)) { propertyScope.PropertyName = childMetadata.PropertyName; if (!this.ValidateNodeAndChildren(childMetadata, validationContext, metadata.Model)) { isValid = false; } } validationContext.KeyBuilders.Pop(); return isValid; }