WcfOperationLifestyle Class

Simple Injector
Defines a lifestyle that caches instances for the lifetime of a WCF service class. WCF allows service classes to be (both implicitly and explicitly) configured to have a lifetime of PerCall, PerSession or Single using the InstanceContextMode enumeration. The lifetime of WCF service classes is controlled by WCF and this lifestyle allows registrations to be scoped according to the containing WCF service class.
Inheritance Hierarchy

SimpleInjectorScopedLifestyle
  SimpleInjector.Integration.WcfWcfOperationLifestyle

Namespace:  SimpleInjector.Integration.Wcf
Assembly:  SimpleInjector.Integration.Wcf (in SimpleInjector.Integration.Wcf.dll) Version: 4.0.0
Syntax

public class WcfOperationLifestyle : ScopedLifestyle

The WcfOperationLifestyle type exposes the following members.

Constructors

  NameDescription
Public methodWcfOperationLifestyle
Initializes a new instance of the WcfOperationLifestyle class. The instance will ensure that created and cached instance will be disposed after the execution of the web request ended and when the created object implements IDisposable.
Public methodWcfOperationLifestyle(Boolean) Obsolete.
Initializes a new instance of the WcfOperationLifestyle class.
Top
Methods

  NameDescription
Protected methodCreateCurrentScopeProvider
Creates a delegate that upon invocation return the current Scope for this lifestyle and the given container, or null when the delegate is executed outside the context of such scope.
Protected methodGetCurrentScopeCore
Returns the current Scope for this lifestyle and the given container, or null when this method is executed outside the context of a scope.
Public methodStatic memberWhenWcfOperationEnds Obsolete.
Allows registering an action delegate that will be called when the current WCF operation ends, but before the scope disposes any instances.
Top
Examples

The following example shows the usage of the WcfOperationLifestyle class:
C#
var container = new Container();
container.Options.DefaultScopedLifestyle = new WcfOperationLifestyle();
container.Register<IUnitOfWork, EntityFrameworkUnitOfWork>(Lifestyle.Scoped);
See Also

Reference