VAB: Internalization Style or Problem?

Topics: General discussion, Validation Application Block
Jul 5, 2007 at 11:39 PM
Are the MyMethod1 and MyMethod2 equivalent with regards to use of the VAB? The later allows me to include default resource strings for globalization in my library assemblies that declare the exceptions. Is there a reason not to do it like MyMethod2, as it also provides much cleaner code to look at? Should class properties still get attributes applied, or are the same type of calls as in MyMethod2 ok? Would that make ValidatorCallHandler not work?

public void MyMethod1( [MyValidator(
MessageTemplateResourceName=MyAssemblyName.ResourceKey.MyCustomMessage
MessageTemplateResourceType=typeof(Resources))] object ID)
{
}

public void MyMethod2(object ID)
{
MyAssemblyName.Validate.Object("ID",ID);
}

// the following is in another assembly where the a custom exception class is declared

public enum ResourceKey
{
public const string MyCustomMessage = "MyCustomMessage";
}

public static class Validate
{
static Validate()
{
}

public static void Object(string name, object MyObject)
{
MyValidator validator = new MyValidator();
if (!validator.Validate(MyObject).IsValid)
{
throw new MyCustomException(string.Format(
CultureInfo.CultureUICulture,
Resources.MyMessage,
name));
}
}
}