Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Chaining function calls

$
0
0

Hi,

 

I have set of functions which needs to chained together and execute them all together and send list of return messages of all functions.

example is as below:

public ReturnResult{

int Id {get; set;}
string Text {get;set;}

}

public class MyClass{

Dictionary<Action, bool> functionsToRun = new Dictionary<Action, bool>() ;

public ReturnResult Func1(){
 ReturnResult  retmsg;
 retmsg.Id= 1;
 retmsg.Text = "Func1";
 ...
 ...
 ...

    return retmsg;
}

public ReturnResult Func2(){
 ReturnResult  retmsg;
 retmsg.Id= 2;
 retmsg.Text = "Func2";
 ...
 ...
 ...

    return retmsg;
}

public ReturnResult Func3(){
 ReturnResult  retmsg;
 retmsg.Id= 3;
 retmsg.Text = "Func3";
 ...
 ...
 ...

    return retmsg;
}


 public void ChainFunctions(){

I want to chain all the functions to call, something like as follows:

functionsToRun.add...
functionsToRun.add...


}


public List<ReturnResult> Execute(){

<< Invoke all the functions that are added and return the list of return messages of the functions >>
}

}

Can anyone please help me how I can achieve the above scenario. Any help is appreciated.

Regards

Padma 

 


Viewing all articles
Browse latest Browse all 8156

Trending Articles