这一节是通过官网的Getting Started的demo加工简化而来,为了单纯说明这个框架的最核心的功能,去掉接口,在Console Application中演示,有兴趣可以看官网原版 —— [ AutoFac Home ]
安装
支持NuGet便捷安装
构建需求环境
需求环境1-打印模块
using System;
namespace Demo
{
public class ConsoleOutput
{
public void Write(string content)
{
Console.WriteLine(content);
}
}
}
需求环境2-打印内容模块
using System;
namespace Demo
{
public class TodayWriter
{
private ConsoleOutput _output;
public TodayWriter(ConsoleOutput ou