Ejemplo n.º 1
0
        public static ModelMetadataItemBuilder <TModel> RenderAction <TModel>([NotNull] this ModelMetadataItemBuilder <TModel> self, Func <HtmlHelper, IHtmlString> action)
        {
            self.Template("RenderAction");

            var settings = self.Item.GetAdditionalSettingOrCreateNew <RenderActionSetting>();

            settings.Action = action;

            return(self);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Indicates that the value would appear as url in display mode.
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static ModelMetadataItemBuilder <string> AsUrl(this ModelMetadataItemBuilder <string> self)
        {
            self.Template("Url");

            if (self.Item.GetValidation <RegularExpressionValidationMetadata>() != null)
            {
                throw new InvalidOperationException(ExceptionMessages.CannotApplyUrlWhenThereIsAnActiveExpression);
            }

            return(Expression(self, UrlExpression, ((UrlErrorMessageResourceType == null) && string.IsNullOrEmpty(UrlErrorMessageResourceName)) ? () => UrlErrorMessage : (Func <string>)null, UrlErrorMessageResourceType, UrlErrorMessageResourceName));
        }
Ejemplo n.º 3
0
        public static ModelMetadataItemBuilder <string> AsEmail([NotNull] this ModelMetadataItemBuilder <string> self)
        {
            self.Template("EmailAddress");

            self.AddAction(
                m =>
            {
                if (m.GetValidation <RegularExpressionValidationMetadata>() != null)
                {
                    throw new InvalidOperationException(ExceptionMessages.CannotApplyEmailWhenThereIsAnActiveExpression);
                }
            });

            return(Expression(self, EmailExpression, ((EmailErrorMessageResourceType == null) && string.IsNullOrEmpty(EmailErrorMessageResourceName)) ? () => EmailErrorMessage : (Func <string>)null, EmailErrorMessageResourceType, EmailErrorMessageResourceName));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Marks the value to render as password element in edit mode.
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> AsPassword(this ModelMetadataItemBuilder <string> self)
 {
     return(self.Template("Password"));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Marks the value to render as text area element in edit mode.
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> AsMultilineText(this ModelMetadataItemBuilder <string> self)
 {
     return(self.Template("MultilineText"));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Indicates that the value would appear as raw html in display mode, so no encoding will be performed.
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> AsHtml(this ModelMetadataItemBuilder <string> self)
 {
     return(self.Template("Html"));
 }