标签:
public interface IServerObject { Person GetPersonInfo(string name,string sex,int age); } public interface IServerObjFactory { IServerObject CreateInstance(); } public class ServerObject:MarshalByRefObject,IServerObject { public Person GetPersonInfo(string name,string sex,int age) { Person person = new Person(); person.Name = name; person.Sex = sex; person.Age = age; return person; } } public class ServerObjFactory:MarshalByRefObject,IServerObjFactory { public IServerObject CreateInstance() { return new ServerObject(); } }
然后再客户端的远程对象中只提供工厂接口和原来的对象接口:
客户端调用
ServerRemoteObject.IServerObject serverObj = serverFactory.CreateInstance();
标签:
原文地址:http://www.cnblogs.com/wangchuang/p/5021164.html