예제 #1
0
        public static IHtmlString ToJsonTranslatedString <TEnum>(this HtmlHelper htmlHelper)
        {
            var enumValue = Enum.GetValues(typeof(TEnum)).Cast <Enum>();
            var entries   = enumValue.Select(value =>
                                             $"\"{value.ToInt()}\": \"{ TranslationsHelper.Get(value)}\"");

            return(htmlHelper.Raw("{" + string.Join(",", entries) + "}"));
        }
예제 #2
0
        static ListItemsHelper()
        {
            var iAuditableType     = typeof(IAuditable);
            var iIdentifiableTypes = typeof(Audit).Assembly.GetTypes().Where(x => iAuditableType.IsAssignableFrom(x) && x != iAuditableType);

            Entities = new List <ReferenceItem>();
            foreach (var identifiableType in iIdentifiableTypes)
            {
                var entityTypeModel = new ReferenceItem()
                {
                    id = identifiableType.Name, text = TranslationsHelper.Get(identifiableType.Name)
                };
                Entities.Add(entityTypeModel);
            }
        }
예제 #3
0
        public static IHtmlString ToEnumString <TViewModel, TEnum>(this HtmlHelper htmlHelper, Expression <Func <TViewModel, TEnum> > memberExpression)
            where TEnum : IComparable
            where TViewModel : class
        {
            var propertyName        = Reflect.GetProperty(memberExpression).Name;
            var enumValue           = Enum.GetValues(typeof(TEnum)).Cast <Enum>();
            var enumToStringBuilder = new StringBuilder();

            foreach (var value in enumValue)
            {
                enumToStringBuilder.AppendLine("<%");
                enumToStringBuilder.AppendLine(string.Format("if(row.{0} === {1}) {{ %>", propertyName, value.ToInt()));
                enumToStringBuilder.AppendLine(TranslationsHelper.Get(value));
                enumToStringBuilder.AppendLine("<% } %>");
            }

            return(htmlHelper.Raw(enumToStringBuilder.ToString()));
        }