How do I get WCF to generate a list or IEnumerable of proxies to the actual object? I'm doing this in a self-hosted application.
Here's what I have:
public interface IRemoteControlGroup {
List<IRemoteControl> GetInstances();
}
public class RemoteControlGroupImpl : IRemoteControlGroup {
public List<IRemoteControl> GetInstances()
{
System.Console.Error.WriteLine("Called GetInstances()");
List<IRemoteControl> list = new List<IRemoteControl>();
// implementation detail: get this list of IRemoteControl objects
return list;
}
}
public interface IRemoteControl {
void Stop();
void Start();
void GetPID();
}
public class RemoteControlImpl : IRemoteControl {
// actual implementation
}
I want WCF to:
- Offer a service,
RemoteControlGroupImpl, defined by the contract onIRemoteControlGroup. - Give me a
List<IRemoteControl>whenIRemoteControlGroup.GetInstances()is called (on the client), where elements of the list are proxies that implementIRemoteControl(by calling the host's actualIRemoteControlobjects).
I don't want WCF to push actual RemoteControlImpl objects through the wire; I just want it to push proxies that implement IRemoteControl. RemoteControlImpl objects actually contain handles to the local system (Window handles, because our apps only expose a GUI interface), and therefore, are not serializable. The number of elements returned by GetInstance() can vary.
I found this article, which sounds like what I want. Kind of. But it doesn't tell me how to do this in code; just in the configuration. It also doesn't quite describe what I want. The entry point for the service delivers a proxy; but I want the entry point for my service to deliver a list of proxies.