我在引导程序配置Automapper和我打电话Bootstrap()
的 Application_Start()
,我一直在说,这是错误的,因为我要修改我的Bootstrapper
每一次我必须添加一个新的映射类,所以我违反了开闭原则.
你觉得怎么样,我真的违反了这个原则吗?
public static class Bootstrapper
{
public static void BootStrap()
{
ModelBinders.Binders.DefaultBinder = new MyModelBinder();
InputBuilder.BootStrap();
ConfigureAutoMapper();
}
public static void ConfigureAutoMapper()
{
Mapper.CreateMap<User, UserDisplay>()
.ForMember(o => o.UserRolesDescription,
opt => opt.ResolveUsing<RoleValueResolver>());
Mapper.CreateMap<Organisation, OrganisationDisplay>();
Mapper.CreateMap<Organisation, OrganisationOpenDisplay>();
Mapper.CreateMap<OrganisationAddress, OrganisationAddressDisplay>();
}
}
Run Code Online (Sandbox Code Playgroud) .net bootstrapping automapper open-closed-principle solid-principles