1、新建asp.net mvc项目,安装Autofac。
【工具】---->【库程序包管理器】---->【程序包管理器控制台】
Install-package autofac (-version 3.5.2)
2、要使用配置文件还需安装Autofac.Configuration
install-package Autofac.Configuration
3、新建项目BUS,接口:IOutput,两个实现:PcWebOutput,CellPhoneOutput,一个使用类:OutputBase
namespace Bus
{
public interface IOutput
{
string Bold(string content);
}
public class PcWebOutput : IOutput
{
public string Bold(string content)
{
return string.Format("<b class=\"pcBlod\">{0}</b>", content);
}
}
public class CellPhoneOutput : IOutput
{
public string Bold(string content)
{
return string.Format("<b class=\"cellPhoneBlod\">{0}</b>", content);
}
}
publi