Interface IContext

Summary description for IContext.

Namespace: EPiServer.BaseLibrary
Assembly: EPiServer.BaseLibrary.dll
Version: 8.11.0
Syntax
public interface IContext

Properties

Item[String]

A general-purpose store for context-bound data.

Declaration
object this[string name] { get; set; }
Parameters
Type Name Description
System.String name
Property Value
Type Description
System.Object
Remarks

If you need specific data to cross application layers and the API:s do not expose this functionality, you may use this store to pass such data. Note that the current context might not be available to object stores since they may reside in separate app domains or even on a different physical machine.

Now

Declaration
DateTime Now { get; }
Property Value
Type Description
System.DateTime

Repository

Get the current repository in use for this context.

Declaration
IRepository Repository { get; }
Property Value
Type Description
IRepository
Remarks

In most cases the repository will be a singleton object for the entire app domain, but this is not a requirement.

RequestTime

Declaration
DateTime RequestTime { get; }
Property Value
Type Description
System.DateTime

Methods

FreezeTime(DateTime)

Lock the time returned by Now.

Declaration
void FreezeTime(DateTime now)
Parameters
Type Name Description
System.DateTime now

The DateTime value to return from Now

Remarks

This time freeze will be in effect until either NormalTime, OffsetTime or another FreezeTime call is made. Note that the time settings flows with the current call context, but it will not flow across threads.

NormalTime()

Removes any freeze or offset to the time.

Declaration
void NormalTime()

OffsetTime(TimeSpan)

Offset the time returned by Now

Declaration
void OffsetTime(TimeSpan offset)
Parameters
Type Name Description
System.TimeSpan offset

The TimeSpan value to add to the current time.

Remarks

This time offset will be in effect until either NormalTime, FreezeTime or another OffsetTime call is made. Note that the time settings flows with the current call context, but it will not flow across threads.

Extension Methods