Programmatically changing code files
Posted
by
Carra
on Stack Overflow
See other posts from Stack Overflow
or by Carra
Published on 2011-01-05T10:37:08Z
Indexed on
2011/01/05
11:53 UTC
Read the original article
Hit count: 247
I'm changing our webservices to an async model. And for that I have to change over a hundred methods.
Doing it manually is one (unappealing) option. Is there no way to programmatically parse & change multiple functions/code files?
Example:
[Webmethod]
public void MyWebservice (string parameter1, string parameter2, string parameter3)
{
//Logic here
}
And change this to:
public void InternalMyWebservice (string parameter1, string parameter2, string parameter3, AsyncCallback callback)
{
//Logic here
}
[Webmethod]
public void BeginMyWebservice (string parameter1, string parameter2, string parameter3, AsyncCallback callback, object asyncState)
{
//Queue InternalMyWebservice in a threadpool
}
public void EndMyWebservice(IAsyncResult asyncResult)
{
//Set return values
}
It's basically the same thing I have to do for each webservice. Change the name to "InternalX", add a parameter and create the begin & end method.
© Stack Overflow or respective owner