Example #1
0
        public static void SetDisplayName(
            this ValidationContext validationContext, InternalMemberEntry property, DisplayAttribute displayAttribute)
        {
            DebugCheck.NotNull(validationContext);

            var displayName = displayAttribute == null ? null : displayAttribute.GetName();

            if (property == null)
            {
                var objectType = ObjectContextTypeCache.GetObjectType(validationContext.ObjectType);
                validationContext.DisplayName = displayName ?? objectType.Name;
                validationContext.MemberName  = null;
            }
            else
            {
                validationContext.DisplayName = displayName ?? DbHelpers.GetPropertyPath(property);
                validationContext.MemberName  = DbHelpers.GetPropertyPath(property);
            }
        }
Example #2
0
        public static void SetDisplayName(
            this ValidationContext validationContext,
            InternalMemberEntry property,
            DisplayAttribute displayAttribute)
        {
            string str = displayAttribute == null ? (string)null : displayAttribute.GetName();

            if (property == null)
            {
                Type objectType = ObjectContextTypeCache.GetObjectType(validationContext.ObjectType);
                validationContext.DisplayName = str ?? objectType.Name;
                validationContext.MemberName  = (string)null;
            }
            else
            {
                validationContext.DisplayName = str ?? DbHelpers.GetPropertyPath(property);
                validationContext.MemberName  = DbHelpers.GetPropertyPath(property);
            }
        }