Pass parameter to a delegate

Pass parameter to a delegate

am 11.10.2007 17:08:25 von Fir5tSight

I have a C#.NET program that uses a delegate,
"BuildExistingReportFile". It's called in such a fashion:

IList lFiles = this.GetListFromStoredProcedure(
null,
Constants.StoredProcedures.SPcorReportInstanceFilesGet,
new BuildDelegate(new
ReportClosure(aReport).BuildExistingReportFile),
new SqlParameter("@ReportInstanceID",aReport.ID));

I don't see any parameter passed to "BuildExistingReportFile".
However, it's defined as below:

public object BuildExistingReportFile(IRecord aRecord)
{
\\blah blah
}

Now I want to add an integer type of parameter, "counter", to this
delegate. How can I pass this parameter in?

Thanks!

Re: Pass parameter to a delegate

am 11.10.2007 20:03:52 von mattias.dont.want.spam

>I have a C#.NET program that uses a delegate,
>"BuildExistingReportFile". It's called in such a fashion:

Looks like the delegate type is actually called BuildDelegate and that
BuildExistingReportFile is the method that the delegate object will
call.


>Now I want to add an integer type of parameter, "counter", to this
>delegate. How can I pass this parameter in?

- Modify the delegate type (BuildDelegate).
- Modify the method signature to match (BuildExistingReportFile).
- Modify the calling code (probably somewhere inside
GetListFromStoredProcedure).


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Pass parameter to a delegate

am 11.10.2007 23:10:34 von Fir5tSight

Mattias,

Thanks for the valuable advice! Sounds like the way to go. I'll try it
out. In case I have question, I'll ask again.