コード例 #1
0
 /// <summary>
 /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
 /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
 public DisplayMetadataProviderContext(
     [NotNull] ModelMetadataIdentity key, 
     [NotNull] IReadOnlyList<object> attributes)
 {
     Key = key;
     Attributes = attributes;
     DisplayMetadata = new DisplayMetadata();
 }
コード例 #2
0
 /// <summary>
 /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
 /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
 public DisplayMetadataProviderContext(
     [NotNull] ModelMetadataIdentity key,
     [NotNull] IReadOnlyList <object> attributes)
 {
     Key             = key;
     Attributes      = attributes;
     DisplayMetadata = new DisplayMetadata();
 }
コード例 #3
0
        /// <summary>
        /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
        /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
        public DisplayMetadataProviderContext(
            [NotNull] ModelMetadataIdentity key,
            [NotNull] ModelAttributes attributes)
        {
            Key                = key;
            Attributes         = attributes.Attributes;
            PropertyAttributes = attributes.PropertyAttributes;
            TypeAttributes     = attributes.TypeAttributes;

            DisplayMetadata = new DisplayMetadata();
        }
コード例 #4
0
        /// <summary>
        /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
        /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
        public DisplayMetadataProviderContext(
            [NotNull] ModelMetadataIdentity key, 
            [NotNull] ModelAttributes attributes)
        {
            Key = key;
            Attributes = attributes.Attributes;
            PropertyAttributes = attributes.PropertyAttributes;
            TypeAttributes = attributes.TypeAttributes;

            DisplayMetadata = new DisplayMetadata();
        }
コード例 #5
0
        /// <summary>
        /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
        /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
        public DisplayMetadataProviderContext(
            ModelMetadataIdentity key,
            ModelAttributes attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            Key                = key;
            Attributes         = attributes.Attributes;
            PropertyAttributes = attributes.PropertyAttributes;
            TypeAttributes     = attributes.TypeAttributes;

            DisplayMetadata = new DisplayMetadata();
        }
コード例 #6
0
        /// <summary>
        /// Creates a new <see cref="DisplayMetadataProviderContext"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
        /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
        public DisplayMetadataProviderContext(
            ModelMetadataIdentity key,
            ModelAttributes attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            Key = key;
            Attributes = attributes.Attributes;
            PropertyAttributes = attributes.PropertyAttributes;
            TypeAttributes = attributes.TypeAttributes;

            DisplayMetadata = new DisplayMetadata();
        }
コード例 #7
0
        private static bool IsTransformRequired(
            string propertyName,
            DisplayMetadata modelMetadata,
            IReadOnlyList<object> propertyAttributes)
        {
            if (!string.IsNullOrEmpty(modelMetadata.SimpleDisplayProperty))
            {
                return false;
            }

            if (propertyAttributes.Any(a => a is DisplayAttribute))
            {
                return false;
            }

            return !string.IsNullOrEmpty(propertyName);
        }