以下是一种使用更新的IRegistrationConvention API的方法:
public class SingletonConvention : IRegistrationConvention { #region IRegistrationConvention Members public void Process(Type type, Registry registry) { registry.For(type).Singleton(); } #endregion }
它可以像这样使用:
container.Configure(registry => { registry.Scan(x => { x.AssemblyContainingType(); x.AddAllTypesOf (); x.Convention (); }); });