我在"自适应代码通过C#"一书中遇到了"Stairway"模式描述,我真的不明白这是如何实现的:
(来源)
所以我有客户端组装:
using ServiceInterface;
namespace Client
{
class Program
{
static void Main(string[] args)
{
// Have to create service implementation somehow
// Where does ServiceFactory belong?
ServiceFactory serviceFactory = new ServiceFactory();
IService service = serviceFactory.CreateService();
service.Do();
}
}
}
Run Code Online (Sandbox Code Playgroud)
服务接口组件:
namespace Service
{
public interface IService
{
void Do();
}
}
Run Code Online (Sandbox Code Playgroud)
和服务实现程序集:
using ServiceInterface;
namespace ServiceImplementation
{
public class PrintService : IService
{
public void Do()
{
Console.WriteLine("Some work done");
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是:如何IService
在 …