asp.net mvc - When accessing resources by property name is it possible to change which ResourceManager is used? -
i want use custom resourceprovider still have benefit of typed resource names. seems though in view if access resource property directly so:
@html.raw(uitext.header)
then text read directly resx file , doesn't go through custom provider factory defined in web.config.
@html.raw(httpcontext.getlocalresourceobject("uitext.resx", "header").tostring())
works fine has down-side of being stringly typed. have created extension method wraps still quite ugly:
@html.resourcetext(() => uitext.header)
so, there way use resource properties directly have them route through custom provider without having create our own resxfilecodegenerator
?
would static class holds strings work you? i've made t4 template file looks @ .resx , generates static class automagically.
this result of t4 template compilation:
public static class resourcestrings { public const string addattachments = @"addattachments"; public const string button_create = @"button_create"; public const string button_delete = @"button_delete"; public const string button_details = @"button_details"; public const string button_display = @"button_display"; ... }
i use asp.net mvc attributes classes this:
[stringlength(8, errormessageresourcetype = typeof(i18n), errormessageresourcename = resourcestrings.client_vatno_length_validation_msg)] public string vatno; [stringlength(10, errormessageresourcetype = typeof (i18n), errormessageresourcename = resourcestrings.client_baseidentnr_length_validation_msg)] public string baseidentnr;
hopefully didn't miss completely;)
Comments
Post a Comment