コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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;
        }