Reputation: 81342
I have a few WCF services I am calling from a console app.
I have methods for setting the binding timeout programatically like this:
private static void InitRepClient(ref Reporting.ReportingClient rc)
{
rc.Endpoint.Binding.CloseTimeout = new TimeSpan(12, 0, 0);
rc.Endpoint.Binding.ReceiveTimeout = new TimeSpan(12, 0, 0);
rc.Endpoint.Binding.SendTimeout = new TimeSpan(12, 0, 0);
rc.Endpoint.Binding.OpenTimeout = new TimeSpan(12, 0, 0);
}
I want to instead change the input parameter to accept any WCF service. So that I don't have to have 1 function for each service. Of what class type should my input parameter be?
Thanks in advance.
Upvotes: 0
Views: 1669
Reputation: 33270
The base type of the client proxies is a generic type ClientBase<T>
. This means that you would need to make your method generic, like this:
private static void InitClient<T>(ClientBase<T> client) where T : class
{
client.Endpoint.Binding.CloseTimeout = new TimeSpan(12, 0, 0);
client.Endpoint.Binding.ReceiveTimeout = new TimeSpan(12, 0, 0);
client.Endpoint.Binding.SendTimeout = new TimeSpan(12, 0, 0);
client.Endpoint.Binding.OpenTimeout = new TimeSpan(12, 0, 0);
}
Upvotes: 1
Reputation: 36320
Could you not pass in the endpoint to be configured instead?
Also you do not need to pass the argument by ref here.
Upvotes: 2