protected override string GetMessage(object objectToValidate, string key) { if (FieldNameResourceType != null && !string.IsNullOrEmpty(FieldNameResourceName)) { _fieldName = FieldNameResourceType.GetProperty(FieldNameResourceName).GetValue(FieldNameResourceType, null).ToString(); } // стойността на за съобщението за грешка се извлича от ресурсите PropertyInfo nameProperty = ErrorMessageResourceType.GetProperty(ErrorMessageResourceName, BindingFlags.Static | BindingFlags.Public); string msg = (string)nameProperty.GetValue(nameProperty.DeclaringType, null); return(String.Format(CultureInfo.CurrentUICulture, msg, !string.IsNullOrEmpty(_fieldName) ? _fieldName : key, this.UpperBound)); }
protected override string GetMessage(object objectToValidate, string key) { //Извличане на името на полето от типа му или от ресурсен файл, ако е от прост тип if (FieldNameResourceType != null && !string.IsNullOrEmpty(FieldNameResourceName)) { _fieldName = FieldNameResourceType.GetProperty(FieldNameResourceName).GetValue(FieldNameResourceType, null).ToString(); } PropertyInfo nameProperty = ErrorMessageResourceType.GetProperty(ErrorMessageResourceName, BindingFlags.Static | BindingFlags.Public); string msg = (string)nameProperty.GetValue(nameProperty.DeclaringType, null); return(String.Format(CultureInfo.CurrentUICulture, msg, _fieldName)); }
protected override string GetMessage(object objectToValidate, string key) { //Извличане на името на полето от типа му или от ресурсен файл, ако е от прост тип if (FieldType != null) { this._fieldName = FieldType.GetDisplayString(); } else if (FieldNameResourceType != null && !string.IsNullOrEmpty(FieldNameResourceName)) { _fieldName = FieldNameResourceType.GetProperty(FieldNameResourceName).GetValue(FieldNameResourceType, null).ToString(); } // стойността на за съобщението за грешка се извлича от ресурсите PropertyInfo nameProperty = ErrorMessageResourceType.GetProperty(ErrorMessageResourceName, BindingFlags.Static | BindingFlags.Public); string msg = (string)nameProperty.GetValue(nameProperty.DeclaringType, null); return(String.Format(CultureInfo.CurrentUICulture, msg, !string.IsNullOrEmpty(_fieldName) ? _fieldName : key, _sectionName)); }