How to setup a Unity Registration Convention?
问题 With structure map, you can register a convention that lets you not just tweak the type, but also intervene during object creation. How can I do this with Unity. public class SettingsRegistration : IRegistrationConvention { public void Process(Type type, Registry registry) { if (!type.IsAbstract && typeof(ISettings).IsAssignableFrom(type)) { registry.For(type).Use(x => { var svc = x.GetInstance<ISettingService>(); return svc.LoadSetting(type); }); } } } 回答1: You can do this with a combination