//客户端激活模式接口
public interface IClientActivator<T>
{
T CreateInstance();
T CreateInstance(params object[] args);
}
// 客户端激活模式抽象类
public abstract class ClientActivator<T, IT> : MarshalByRefObject, IClientActivator<IT>
where T : class, IT,new()
//where IT:IDisposable
{
public virtual IT CreateInstance()
{
return new T();
}
public virtual IT CreateInstance(params object[] args)
{
return (IT)Activator.CreateInstance(this.GetType(), args);
}
}
//服务接口...
public interface IServerObject
{
void WriteName();
}
//服务类
public class ServerObject : ClientActivator<ServerObject, IServerObject>, IServerObject
{
public virtual void WriteName()
{
Console.WriteLine("ServerObjectCall");
}
}