我正在关注此链接: http ://codebetter.com/jpboodhoo/2007/10/15/the-static-gateway-pattern/ 以了解网关模式。
作者分享了一个“网关”记录器类和相关接口的示例:
public class Log
{
private static ILogFactory logFactory;
public static void InitializeLogFactory(ILogFactory logFactory)
{
Log.logFactory = logFactory;
}
public void InformationalMessage(string informationalMessage)
{
logFactory.Create().InformationalMessage(informationalMessage);
}
}
public interface ILogFactory
{
ILog Create();
}
public interface ILog
{
void InformationalMessage(string message);
}
这是调用 API
public class Calculator
{
public int Add(int number1,int number2)
{
Log.InformationalMessage("About to add two numbers");
return number1 + number2;
}
}
我无法理解具体日志记录类的初始化发生在哪里。网关的入口点是什么?