/// <summary>
 /// Marks the value to render partial action.
 /// </summary>
 /// <param name="self">The instance.</param>
 /// <param name="actionName">The name of the action which should be rendered.</param>
 /// <param name="controllerName">The name of the controller that contains the action.</param>
 /// <param name="routeValues">An object that contains the parameters for a route. You can use <paramref name="routeValues"/> to provide the parameters that are bound to the action method parameters. The <paramref name="routeValues"/> parameter is merged with the original route values and overrides them.</param>
 /// <typeparam name="TModel">Type of the model.</typeparam>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TModel> RenderAction <TModel>(this ModelMetadataItemBuilder <TModel> self, string actionName, string controllerName, object routeValues)
 {
     return(RenderAction(self, html => html.Action(actionName, controllerName, routeValues)));
 }
Esempio n. 2
0
 /// <summary>
 /// Sets the minimum length of the value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="length">The length.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> MinimumLength(this ModelMetadataItemBuilder <string> self, int length)
 {
     return(MinimumLength(self, length, null, null, null));
 }
Esempio n. 3
0
 /// <summary>
 /// Sets the minimum length of the value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="length">The length.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> MinimumLength(this ModelMetadataItemBuilder <string> self, int length, Func <string> errorMessage)
 {
     return(MinimumLength(self, length, errorMessage, null, null));
 }
Esempio n. 4
0
 /// <summary>
 /// Sets the regular expression that the value must match, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="pattern">The pattern.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> Expression(this ModelMetadataItemBuilder <string> self, string pattern)
 {
     return(Expression(self, pattern, null, null, null));
 }
Esempio n. 5
0
 /// <summary>
 /// Sets the regular expression that the value must match, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="pattern">The pattern.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> Expression(this ModelMetadataItemBuilder <string> self, string pattern, Func <string> errorMessage)
 {
     return(Expression(self, pattern, errorMessage, null, null));
 }
Esempio n. 6
0
 /// <summary>
 /// Creates a set of model metadata rules
 /// </summary>
 /// <param name="property">The property</param>
 /// <param name="builder">The model metadata item builder</param>
 protected virtual void Apply(PropertyInfo property, ModelMetadataItemBuilder <T> builder)
 {
 }
Esempio n. 7
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"));
 }
Esempio n. 8
0
 public static ModelMetadataItemBuilder <TValue> AsDropDownList <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey, Func <string> optionLabel)
 {
     return(self.AsDropDownList(viewDataKey, optionLabel, "DropDownList"));
 }
Esempio n. 9
0
 public static ModelMetadataItemBuilder <TValue> AsDropDownList <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey, string optionLabel, [AspMvcEditorTemplate, AspMvcDisplayTemplate] string template)
 {
     return(self.AsDropDownList(viewDataKey, () => optionLabel, template));
 }
Esempio n. 10
0
 public static ModelMetadataItemBuilder <TValue> AsListBox <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey, [AspMvcEditorTemplate, AspMvcDisplayTemplate] string template)
 {
     return(HtmlSelect(self, template, viewDataKey, null));
 }
Esempio n. 11
0
 public static ModelMetadataItemBuilder <TValue> AsDropDownList <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey)
 {
     return(self.AsDropDownList(viewDataKey, (Func <string>)null));
 }
Esempio n. 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="self"></param>
 /// <param name="configure"></param>
 /// <param name="errorMessageResourceName"></param>
 /// <param name="errorMessageResourceType"></param>
 /// <typeparam name="TValue"></typeparam>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TValue> Remote <TValue>(this ModelMetadataItemBuilder <TValue> self, [NotNull] Func <RemoteValidationConfigurator <TValue>, AbstractRemoteValidationConfigurator <TValue> > configure, string errorMessageResourceName, Type errorMessageResourceType)
 {
     return(Remote(self, configure, null, errorMessageResourceName, errorMessageResourceType));
 }
Esempio n. 13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="self"></param>
 /// <param name="configure"></param>
 /// <param name="errorMessage"></param>
 /// <typeparam name="TValue"></typeparam>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TValue> Remote <TValue>(this ModelMetadataItemBuilder <TValue> self, [NotNull] Func <RemoteValidationConfigurator <TValue>, AbstractRemoteValidationConfigurator <TValue> > configure, Func <string> errorMessage)
 {
     return(Remote(self, configure, errorMessage, null, null));
 }
 /// <summary>
 /// Marks the value to render partial action.
 /// </summary>
 /// <param name="self">The instance.</param>
 /// <param name="actionName">The name of the action which should be rendered.</param>
 /// <param name="routeValues">A dictionary that contains the parameters for a route. You can use <paramref name="routeValues"/> to provide the parameters that are bound to the action method parameters. The <paramref name="routeValues"/> parameter is merged with the original route values and overrides them.</param>
 /// <typeparam name="TModel">Type of the model.</typeparam>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TModel> RenderAction <TModel>(this ModelMetadataItemBuilder <TModel> self, string actionName, RouteValueDictionary routeValues)
 {
     return(RenderAction(self, html => html.Action(actionName, routeValues)));
 }
 /// <summary>
 /// Sets the range of value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self">The instance.</param>
 /// <param name="otherProperty">The other property.</param>
 /// <param name="expression"></param>
 /// <param name="errorMessageResourceType">Type of the error message resource.</param>
 /// <param name="errorMessageResourceName">Name of the error message resource.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TValue> RequiredIfRegExMatch <TValue>(this ModelMetadataItemBuilder <TValue> self, string otherProperty, string expression, Type errorMessageResourceType, string errorMessageResourceName)
 {
     return(RequiredIfRegExMatch(self, otherProperty, expression, null, errorMessageResourceType, errorMessageResourceName));
 }
Esempio n. 16
0
 public static ModelMetadataItemBuilder <TValue> AsDropDownList <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey, Func <string> optionLabel, [AspMvcEditorTemplate, AspMvcDisplayTemplate] string template)
 {
     return(HtmlSelect(self, template, viewDataKey, optionLabel));
 }
        /// <summary>
        /// Sets the range of value, this comes into action when is <code>Required</code> is <code>true</code>.
        /// </summary>
        /// <param name="self">The instance.</param>
        /// <param name="otherProperty">The other property.</param>
        /// <param name="expression"></param>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="errorMessageResourceType">Type of the error message resource.</param>
        /// <param name="errorMessageResourceName">Name of the error message resource.</param>
        /// <returns></returns>
        private static ModelMetadataItemBuilder <TValue> RequiredIfRegExMatch <TValue>(this ModelMetadataItemBuilder <TValue> self, string otherProperty, string expression, Func <string> errorMessage, Type errorMessageResourceType, string errorMessageResourceName)
        {
            var validation = self.Item.GetValidationOrCreateNew <RequiredIfRegExMatchAttributeMetadata>();

            validation.OtherProperty            = otherProperty;
            validation.Expression               = expression;
            validation.ErrorMessage             = errorMessage;
            validation.ErrorMessageResourceType = errorMessageResourceType;
            validation.ErrorMessageResourceName = errorMessageResourceName;

            return(self);
        }
Esempio n. 18
0
 public static ModelMetadataItemBuilder <TValue> AsListBox <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, string viewDataKey)
 {
     return(self.AsListBox(viewDataKey, "ListBox"));
 }
Esempio n. 19
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"));
 }
Esempio n. 20
0
 public static ModelMetadataItemBuilder <TValue> Range <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, TValue minimum, TValue maximum, Func <string> errorMessage)
     where TValue : IComparable
 {
     return(self.Range(minimum, maximum, errorMessage, null, null));
 }
Esempio n. 21
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"));
 }
Esempio n. 22
0
 public static ModelMetadataItemBuilder <TValue> Range <TValue>([NotNull] this ModelMetadataItemBuilder <TValue> self, TValue minimum, TValue maximum, Type errorMessageResourceType, string errorMessageResourceName)
     where TValue : IComparable
 {
     return(self.Range(minimum, maximum, null, errorMessageResourceType, errorMessageResourceName));
 }
Esempio n. 23
0
 /// <summary>
 /// Sets the regular expression that the value must match, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="pattern">The pattern.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> Expression(this ModelMetadataItemBuilder <string> self, string pattern, string errorMessage)
 {
     return(Expression(self, pattern, () => errorMessage));
 }
Esempio n. 24
0
 public static ModelMetadataItemBuilder <TValue?> Range <TValue>([NotNull] this ModelMetadataItemBuilder <TValue?> self, TValue minimum, TValue maximum)
     where TValue : struct, IComparable
 {
     return(self.Range(minimum, maximum, null, null, null));
 }
Esempio n. 25
0
 /// <summary>
 /// Sets the regular expression that the value must match, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="pattern">The pattern.</param>
 /// <param name="errorMessageResourceType">Type of the error message resource.</param>
 /// <param name="errorMessageResourceName">Name of the error message resource.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> Expression(this ModelMetadataItemBuilder <string> self, string pattern, Type errorMessageResourceType, string errorMessageResourceName)
 {
     return(Expression(self, pattern, null, errorMessageResourceType, errorMessageResourceName));
 }
Esempio n. 26
0
 public static ModelMetadataItemBuilder <TValue?> Range <TValue>([NotNull] this ModelMetadataItemBuilder <TValue?> self, TValue minimum, TValue maximum, string errorMessage)
     where TValue : struct, IComparable
 {
     return(self.Range(minimum, maximum, () => errorMessage));
 }
Esempio n. 27
0
 /// <summary>
 /// Sets the minimum length of the value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="length">The length.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> MinimumLength(this ModelMetadataItemBuilder <string> self, int length, string errorMessage)
 {
     return(MinimumLength(self, length, () => errorMessage));
 }
 /// <summary>
 /// Sets the range of value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self">The instance.</param>
 /// <param name="otherProperty">The other property.</param>
 /// <param name="expression"></param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TValue> RequiredIfRegExMatch <TValue>(this ModelMetadataItemBuilder <TValue> self, string otherProperty, string expression, Func <string> errorMessage)
 {
     return(RequiredIfRegExMatch(self, otherProperty, expression, errorMessage, null, null));
 }
Esempio n. 29
0
 /// <summary>
 /// Sets the minimum length of the value, this comes into action when is <code>Required</code> is <code>true</code>.
 /// </summary>
 /// <param name="self"></param>
 /// <param name="length">The length.</param>
 /// <param name="errorMessageResourceType">Type of the error message resource.</param>
 /// <param name="errorMessageResourceName">Name of the error message resource.</param>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <string> MinimumLength(this ModelMetadataItemBuilder <string> self, int length, Type errorMessageResourceType, string errorMessageResourceName)
 {
     return(MinimumLength(self, length, null, errorMessageResourceType, errorMessageResourceName));
 }
 /// <summary>
 /// Marks the value to render partial action.
 /// </summary>
 /// <param name="self">The instance.</param>
 /// <param name="actionName">The name of the action which should be rendered.</param>
 /// <typeparam name="TModel">Type of the model.</typeparam>
 /// <returns></returns>
 public static ModelMetadataItemBuilder <TModel> RenderAction <TModel>(this ModelMetadataItemBuilder <TModel> self, string actionName)
 {
     return(RenderAction(self, html => html.Action(actionName)));
 }