WCF: How to create a method that will allow me to pass in and operate on an array of proxies with various types?
I was wondering if 开发者_JAVA技巧anyone can come up with a way that I can set the ClientCredentials of all my proxies using a single method call. For example, if I have:
public class ServiceOneClient : ClientBase<IServiceOne>, IServiceOne
...
public class ServiceTwoClient : ClientBase<IServiceTwo>, IServiceTwo
...
how can I create a method that I can call like this?
SetProxyCredentials(serviceOneClient, serviceTwoClient);
not sure if its possible through an array since each proxy will have its own interface but maybe this would help :
public static void SetProxyCredential<T>(ClientBase<T> proxy) where T : class
{
//set credential
}
you could then call SetProxyCrendential<IMyInterface>(proxy);
精彩评论