我将使用类派生模式将两个不同的类分离。派生类必须密封,并且以下代码不会调用基础构造函数中的restServer.Start()
。
class RESTService : RESTResource
{
public static RESTServer restServer = new RESTServer();
public RESTService()
{
restServer.Start();
}
}
sealed class Program : RESTService
{
Program() : base()
{
}
static void Main(string[] args)
{
}
}