public static IEnumerable <ModelExplorer> Contextualize(this ModelExplorer modelExplorer, IModelMetadataProvider metadataProvider) { var propertiesFields = modelExplorer.GetFieldValue("_properties"); if (propertiesFields == null && modelExplorer.Model is ICustomTypeDescriptor) { ICustomTypeDescriptor model = modelExplorer.Model as ICustomTypeDescriptor; var metadata = GetMetadataForRuntimeType(modelExplorer, metadataProvider); var properties = metadata.Properties; var propertyDescriptors = model.GetProperties(); var _properties = new ModelExplorer[properties.Count]; for (var i = 0; i < properties.Count; i++) { var propertyMetadata = properties[i]; PropertyDescriptor propertyDescriptor = null; for (var j = 0; j < propertyDescriptors.Count; j++) { if (string.Equals( propertyMetadata.PropertyName, propertyDescriptors[j].Name, StringComparison.Ordinal)) { propertyDescriptor = propertyDescriptors[j]; break; } } _properties[i] = CreateExplorerForProperty(metadataProvider, modelExplorer, propertyMetadata, propertyDescriptor); } modelExplorer.SetFieldValue("_properties", _properties); } return(modelExplorer.Properties); }