Class Context
A base implementation for contexts.
Inheritance
Implements
Inherited Members
Namespace: Kephas.Services
Assembly: Kephas.Core.dll
Syntax
public class Context : Expando, IContext, IExpando, IDynamicMetaObjectProvider, IIndexable, ILoggable, IDisposable
Constructors
| Improve this Doc View SourceContext()
Initializes a new instance of the Context class.
Declaration
[Obsolete("In the near future it will be allowed only to pass a composition context to the context constructor.")]
protected Context()
Context(ICompositionContext, Boolean)
Initializes a new instance of the Context class.
Declaration
public Context(ICompositionContext compositionContext, bool isThreadSafe = false)
Parameters
Type | Name | Description |
---|---|---|
ICompositionContext | compositionContext | The context for the composition (optional). If not provided, AmbientServices.Instance.CompositionContainer will be considered. |
System.Boolean | isThreadSafe |
|
Context(IAmbientServices, Boolean)
Initializes a new instance of the Context class.
Declaration
public Context(IAmbientServices ambientServices, bool isThreadSafe = false)
Parameters
Type | Name | Description |
---|---|---|
IAmbientServices | ambientServices | The ambient services. |
System.Boolean | isThreadSafe |
|
Context(IContext, Boolean, Boolean)
Initializes a new instance of the Context class.
Declaration
public Context(IContext parentContext, bool isThreadSafe = false, bool merge = false)
Parameters
Type | Name | Description |
---|---|---|
IContext | parentContext | The parent context. |
System.Boolean | isThreadSafe | Optional. |
System.Boolean | merge | Optional. True to merge the parent context into the new context. |
Properties
| Improve this Doc View SourceAmbientServices
Gets the ambient services.
Declaration
public IAmbientServices AmbientServices { get; }
Property Value
Type | Description |
---|---|
IAmbientServices |
CompositionContext
Gets the dependency injection/composition context.
Declaration
public ICompositionContext CompositionContext { get; }
Property Value
Type | Description |
---|---|
ICompositionContext |
Identity
Gets or sets the authenticated user.
Declaration
public IIdentity Identity { get; set; }
Property Value
Type | Description |
---|---|
System.Security.Principal.IIdentity |
Logger
Gets or sets the context logger.
Declaration
public ILogger Logger { get; set; }
Property Value
Type | Description |
---|---|
ILogger | The context logger. |
Methods
| Improve this Doc View SourceDispose()
Releases the unmanaged resources used by the Kephas.Services.Context and optionally releases the managed resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases the unmanaged resources used by the Kephas.Services.Context and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | True to release both managed and unmanaged resources; false to release only unmanaged resources. |
SetAmbientServices(IAmbientServices)
Sets ambient services.
Declaration
protected virtual void SetAmbientServices(IAmbientServices ambientServices)
Parameters
Type | Name | Description |
---|---|---|
IAmbientServices | ambientServices | The ambient services (optional). If not provided, AmbientServices.Instance will be considered. |
Remarks
The composition context is also set as the one exposed by the ambient services.
SetCompositionContext(ICompositionContext)
Sets composition context.
Declaration
protected virtual void SetCompositionContext(ICompositionContext compositionContext)
Parameters
Type | Name | Description |
---|---|---|
ICompositionContext | compositionContext | The context for the composition (optional). If not provided, AmbientServices.Instance.CompositionContainer will be considered. |
ValidateIdentity(IIdentity, IIdentity)
Validates the identity before changing it.
Declaration
protected virtual bool ValidateIdentity(IIdentity currentValue, IIdentity newValue)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Principal.IIdentity | currentValue | The current value. |
System.Security.Principal.IIdentity | newValue | The new value. |
Returns
Type | Description |
---|---|
System.Boolean | True if validation succeeds, false if it fails. |