Language: C#
Double dispatch for Parameters
public class StoredProcedureGateway : IExternalSystemGateway { public object Call(string procedure, object[] params) { // call sproc } } public class SomeStoredProcedureParameters : IIssueExternalCalls { public string SomeString; public int SomeInt; public object IssueWith(IExternalSystemGateway gateway) { gateway.Call("Some_StoredProcedure", SomeString, SomeInt); } } public class OtherStoredProcedureParameters : IIssueExternalCalls { public string OtherString1; public string OtherString2; public object IssueWith(IExternalSystemGateway gateway) { gateway.Call("Other_StoredProcedure", OtherString1, OtherString2); } } public interface IIssueExternalCalls { object IssueWith(IExternalSystemGateway gateway); } /////////////////////////// //Usage /////////////////////////// public class MainLoop() { readonly IExternalSystemGateway gateway; public Run(params IIssueExternalCalls[] calls) { foreach(var call in calls) call.IssueWith(gateway); }
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

