Registering types as themselves.

This enables scenarios where you want to instantiate a particular type without having to manually resolve all of its dependencies.
This commit is contained in:
Sipke Schoorstra
2015-07-14 15:38:47 +01:00
parent 21df6cbedd
commit a926e7b8fa

View File

@@ -69,7 +69,7 @@ namespace Orchard.Environment.ShellBuilders {
foreach (var interfaceType in item.Type.GetInterfaces() foreach (var interfaceType in item.Type.GetInterfaces()
.Where(itf => typeof(IDependency).IsAssignableFrom(itf) .Where(itf => typeof(IDependency).IsAssignableFrom(itf)
&& !typeof(IEventHandler).IsAssignableFrom(itf))) { && !typeof(IEventHandler).IsAssignableFrom(itf))) {
registration = registration.As(interfaceType); registration = registration.As(interfaceType).AsSelf();
if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) { if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) {
registration = registration.InstancePerMatchingLifetimeScope("shell"); registration = registration.InstancePerMatchingLifetimeScope("shell");
} }