trying to localize
This commit is contained in:
parent
a93573dce8
commit
b9a75b71b8
32 changed files with 510 additions and 68 deletions
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
|
||||
{
|
||||
public YaValidationAttribute(string msg) : base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public YaValidationAttribute(Func<string> acr): base(acr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
if (ErrorMessageResourceType == null) // failed :/
|
||||
return name;
|
||||
if (ErrorMessageResourceName == null) // re failed :/
|
||||
return name;
|
||||
|
||||
var prop = this.ErrorMessageResourceType.GetProperty(ErrorMessageResourceName);
|
||||
if (prop==null) // re re failed :/
|
||||
return "noprop "+ErrorMessageResourceName+" in "+ErrorMessageResourceType.Name;
|
||||
return (string) prop.GetValue(null, null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue