Programmatically changing code files
- by Carra
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.