diff --git a/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs b/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs index c189ced00..bc79034ce 100644 --- a/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs +++ b/src/Orchard/Environment/ShellBuilders/ShellContainerFactory.cs @@ -71,6 +71,9 @@ namespace Orchard.Environment.ShellBuilders { registration = registration.As(interfaceType); if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) { registration = registration.InstancePerMatchingLifetimeScope("shell"); + } + else if (typeof(IUnitOfWorkDependency).IsAssignableFrom(interfaceType)) { + registration = registration.InstancePerMatchingLifetimeScope("work"); } else if (typeof(ITransientDependency).IsAssignableFrom(interfaceType)) { registration = registration.InstancePerDependency(); diff --git a/src/Orchard/IDependency.cs b/src/Orchard/IDependency.cs index 82262c5af..3f60961d1 100644 --- a/src/Orchard/IDependency.cs +++ b/src/Orchard/IDependency.cs @@ -14,12 +14,20 @@ namespace Orchard { public interface ISingletonDependency : IDependency { } + /// + /// Base interface for services that may *only* be instantiated in a unit of work. + /// This interface is used to guarantee they are not accidentally referenced by a singleton dependency. + /// + public interface IUnitOfWorkDependency : IDependency { + } + /// /// Base interface for services that are instantiated per usage. /// public interface ITransientDependency : IDependency { } + public abstract class Component : IDependency { protected Component() { Logger = NullLogger.Instance;