Example #1
0
        public override MvcHtmlString Render(MenuItemBase menuItem, MvcHtmlString renderedChilds)
        {
            if (!menuItem.IsRenderable)
            {
                return(MvcHtmlString.Empty);
            }

            var nonClickableMenuItem = (NonClickableMenuItem)menuItem;

            var linkText = ValidationMessageFormatter.WithKey(nonClickableMenuItem.ResourceKey);

            var hasChilds = !MvcHtmlString.IsNullOrEmpty(renderedChilds);

            if (hasChilds)
            {
                var mvcHtmlBuilder = new MvcHtmlStringBuilder();

                mvcHtmlBuilder.Append("<ul class=\"dropdown-menu\">");
                mvcHtmlBuilder.Append(renderedChilds);
                mvcHtmlBuilder.Append("</ul>");

                renderedChilds = mvcHtmlBuilder.ToString();
            }

            return(MvcHtmlString.Create(string.Format(NON_CLICKABLE_MENU_ITEM, hasChilds ? " class=\"dropdown\"" : "", hasChilds ? " class=\"dropdown-toggle\"" : "", linkText, renderedChilds)));
        }
Example #2
0
        public void AddPropertyResourceError <T>(Expression <Func <T, object> > property, string key, params object[] args) where T : class
        {
            var propertyName = property.GetPropertyName();

            var resourceValue = ValidationMessageFormatter.WithKey(key, args);

            Errors.Add(propertyName, resourceValue);
        }
Example #3
0
        public override MvcHtmlString Render(SectionItemBase sectionItem)
        {
            if (!sectionItem.IsRenderable)
            {
                return(MvcHtmlString.Empty);
            }

            var heroUnitSectionItem = (HeroUnitSectionItem)sectionItem;

            var titleText       = ValidationMessageFormatter.WithKey(heroUnitSectionItem.TitleKey);
            var descriptionText = ValidationMessageFormatter.WithKey(heroUnitSectionItem.DescriptionKey);

            return(MvcHtmlString.Create(string.Format(SUB_HERO_UNIT_SECTION_ITEM, titleText, descriptionText)));
        }
Example #4
0
        public override MvcHtmlString Render(SectionItemBase sectionItemBase)
        {
            if (!sectionItemBase.IsRenderable)
            {
                return(MvcHtmlString.Empty);
            }

            var sectionItem = (SectionItem)sectionItemBase;

            var titleText       = ValidationMessageFormatter.WithKey(sectionItem.TitleKey);
            var descriptionText = ValidationMessageFormatter.WithKey(sectionItem.DescriptionKey);

            var link = _htmlHelper.LocalizedRouteLink(sectionItem.TitleKey, sectionItem.RouteName, sectionItem.RouteValues, new {
                @class = "btn"
            }, null, false);

            return(MvcHtmlString.Create(string.Format(SECTION_ITEM, titleText, descriptionText, link)));
        }
        public override MvcHtmlString Render(MenuItemBase menuItemBase, MvcHtmlString renderedChilds)
        {
            if (!menuItemBase.IsRenderable)
            {
                return(MvcHtmlString.Empty);
            }

            var menuItem = menuItemBase as MenuItem;

            if (menuItem != null)
            {
                var link = _htmlHelper.LocalizedRouteLink(menuItem.ResourceKey, menuItem.RouteName, menuItem.RouteValues, surroundUsing: null);

                return(MvcHtmlString.Create(string.Format(MENU_ITEM, link, renderedChilds)));
            }

            var nonClickableMenuItem = (NonClickableMenuItem)menuItemBase;

            var linkText = ValidationMessageFormatter.WithKey(nonClickableMenuItem.ResourceKey);

            return(MvcHtmlString.Create(string.Format(NON_CLICKABLE_MENU_ITEM, linkText, renderedChilds)));
        }
Example #6
0
        public static IChainableConstraint <TConstraints> WithInvalidLength <TConstraints>(this IChainableConstraint <TConstraints> chainableConstraint, string labelKey, int length) where TConstraints : class
        {
            var message = ValidationMessageFormatter.InvalidLengthKey(labelKey, length);

            return(chainableConstraint.WithMessage(message));
        }
Example #7
0
 private static string MakeErrorString(string displayName)
 {
     return(ValidationMessageFormatter.InvalidFormatName(displayName));
 }
Example #8
0
 public override string FormatErrorMessage(string name)
 {
     return(ValidationMessageFormatter.InvalidMaxValueName(name, _max));
 }
        public static void AddDuplicate <TEntity, TProperty>(this IConstraintValidatorContext constraintValidatorContext, string key, Expression <Func <TEntity, TProperty> > property)
        {
            var message = ValidationMessageFormatter.DuplicateValueKey(key);

            constraintValidatorContext.AddInvalid(message, property);
        }
Example #10
0
 public static string T(this HtmlHelper htmlHelper, string text, params object[] args)
 {
     return(ValidationMessageFormatter.WithKey(text, args));
 }
        public static void WithInvalidFormat(this IRuleArgsOptions ruleArgsOptions, string labelKey)
        {
            var message = ValidationMessageFormatter.InvalidFormatKey(labelKey);

            ruleArgsOptions.WithMessage(message);
        }
        public static void WithInvalidRange(this IRuleArgsOptions ruleArgsOptions, string labelKey, int minValue, int maxValue)
        {
            var message = ValidationMessageFormatter.OutOfRangeValueKey(labelKey, minValue, maxValue);

            ruleArgsOptions.WithMessage(message);
        }
 public override string FormatErrorMessage(string name)
 {
     return(ValidationMessageFormatter.InvalidLengthName(name, MaximumLength));
 }
        public static void AddLocalizedInvalid(this IConstraintValidatorContext constraintValidatorContext, string key)
        {
            var message = ValidationMessageFormatter.WithKey(key);

            constraintValidatorContext.AddInvalid(message);
        }
Example #15
0
        public static IChainableConstraint <TConstraints> WithRequired <TConstraints>(this IChainableConstraint <TConstraints> chainableConstraint, string labelKey) where TConstraints : class
        {
            var message = ValidationMessageFormatter.RequiredKey(labelKey);

            return(chainableConstraint.WithMessage(message));
        }
Example #16
0
        public void AddResourceError(string key, params object[] args)
        {
            var resourceValue = ValidationMessageFormatter.WithKey(key, args);

            Errors.Add(string.Empty, resourceValue);
        }
        public static void WithLocalized(this IRuleArgsOptions ruleArgsOptions, string key)
        {
            var message = ValidationMessageFormatter.WithKey(key);

            ruleArgsOptions.WithMessage(message);
        }
 public override string FormatErrorMessage(string name)
 {
     return(ValidationMessageFormatter.RequiredName(name));
 }
        public static void WithRequired(this IRuleArgsOptions ruleArgsOptions, string labelKey)
        {
            var message = ValidationMessageFormatter.RequiredKey(labelKey);

            ruleArgsOptions.WithMessage(message);
        }
 public ValidationMessageFormatterTests()
 {
     _sut = new ValidationMessageFormatter();
 }
        public static void AddInvalidLength <TEntity, TProperty>(this IConstraintValidatorContext constraintValidatorContext, string key, int length, Expression <Func <TEntity, TProperty> > property)
        {
            var message = ValidationMessageFormatter.InvalidLengthKey(key, length);

            constraintValidatorContext.AddInvalid(message, property);
        }