vb.net - Message Properties File -


is there vb equivalent org.springframework.context.support.resourcebundlemessagesource package in java?

i not focusing on spring question. want know if there way have message properties file can pass variables can hat java package.

here example of do.

in properties file have following line:

success.message = created document trans no. {0} 

in source code have line:

resourcebundlemessagesource.getmessage("success.message",new string[] {transobject.gettransid()}, null)); 

this code uses properties file finds success.message , passes variable gettransid().

i want centralize error messages. , not have hard coded messages throughout code.

is there kind of equivalent in vb?

one solution use resource files. add resource right clicking on project , selecting project properties. click on resources, , add new resource.

we work example in question : resources cannot follow sam naming convention see above. need replace '.' '_' ie: success.message -> success_message resource files not allow '.' in key name.

next need message resource file. "{0} submitted file." use {0}....{x} place holders variables.

the first line in resource tab should this

success_message | {0} submitted file. 

the function replacing of place holders should this:

public shared function messageretriver(byval message string, byval variables string()) string     dim integer     dim pattern string     = 0 variables.length - 1         pattern = "\x7b" & & "\x7d"         dim myregex new regex(pattern)         message = myregex.replace(message, variables(i))     next     return message end function 

now in code have call function passing resource, , string array of variables.

utility.messageretriver(my.resources.success_message, {"my program"}) 

that should trick. used this resource compile information.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -