//Ici le modelAccessor est celui de la propriété
        public ModelMetadata GetModelPropertyMetadata(ModelMetadataProvider provider, Func <object> modelAccessor, Type containerType, string propertyName)
        {
            ValidateContainerTypeIsContent(containerType);

            if (propertyName == "Id")
            {
                return(GetContentContentIdModelMetadata(provider, containerType, modelAccessor: modelAccessor));
            }

            if (propertyName == "Culture")
            {
                return(GetContentCultureModelMetadata(provider, containerType, modelAccessor: modelAccessor));
            }

            if (propertyName == "ContentTypeFullName")
            {
                return(GetContentContentTypeFullNameModelMetadata(provider, containerType, modelAccessor: modelAccessor));
            }

            var contentType = _contentManager.LoadContentType(_contentManager.GetContentTypeFullNameFromPropertyFullName(propertyName));

            if (containerType == null)
            {
                throw new InvalidOperationException("Cannot create metadata for unknown content type of property: " + propertyName);
            }

            IContentTypeProperty contentTypeProperty;

            return(contentType.TryGetProperty(propertyName, out contentTypeProperty) ?
                   GetContentModelMetadata(provider, contentTypeProperty, containerType, modelAccessor, GetTypeOrDefaultType(contentTypeProperty), contentTypeProperty.FullName) : null);
        }
Example #2
0
 public string GetContentTypeFullNameFromPropertyFullName(string propertyFullName)
 {
     return(_contentManager.GetContentTypeFullNameFromPropertyFullName(propertyFullName));
 }