Show / Hide Table of Contents

Class WorkContext

Represents a context for request/response server processing in WAVE framework

Inheritance
System.Object
DisposableObject
WorkContext
Implements
System.IDisposable
Inherited Members
DisposableObject.DisposeAndNull<T>(T)
DisposableObject.DisposeStarted
DisposableObject.Disposed
DisposableObject.EnsureObjectNotDisposed()
DisposableObject.Dispose()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: NFX.Wave
Assembly: NFX.Wave.dll
Syntax
public class WorkContext : DisposableObject, IDisposable

Properties

Aborted

Indicates whether the work context is logically finished and its nested processing (i.e. through Filters/Handlers) should stop. For example, when some filter detects a special condition (judging by the request) and generates the response and needs to abort the work request so it does no get filtered/processed anymore, it can set this property to true. This mechanism performs much better than throwing exceptions

Declaration
public bool Aborted { get; set; }
Property Value
Type Description
System.Boolean

About

Generates short context description

Declaration
public string About { get; }
Property Value
Type Description
System.String

EffectiveCallerIPEndPoint

Returns the effective caller endpoint- that is, if the real caller filter is set it will inject the real IP as seen before any proxy devices. By default this property returns the Request.RemoteEndPoint

Declaration
public IPEndPoint EffectiveCallerIPEndPoint { get; }
Property Value
Type Description
System.Net.IPEndPoint

GeoEntity

Gets sets geo location information as detected by GeoLookupHandler. If Session context is injected then get/set passes through into session object

Declaration
public GeoEntity GeoEntity { get; set; }
Property Value
Type Description
GeoEntity

Handled

Returns true when the work has been executed by the WorkHandler instance

Declaration
public bool Handled { get; }
Property Value
Type Description
System.Boolean

Handler

Returns the work handler instance that was matched to perform work on this context or null if the match has not been made yet

Declaration
public WorkHandler Handler { get; }
Property Value
Type Description
WorkHandler

ID

Uniquely identifies the request

Declaration
public Guid ID { get; }
Property Value
Type Description
System.Guid

IsAuthenticated

Returns true to indicate that this context is/was authenticated. Used to not redirect users to login page on authorization exception

Declaration
public bool IsAuthenticated { get; }
Property Value
Type Description
System.Boolean

IsDELETE

Indicates that request method id DELETE

Declaration
public bool IsDELETE { get; }
Property Value
Type Description
System.Boolean

IsGET

Indicates that request method id GET

Declaration
public bool IsGET { get; }
Property Value
Type Description
System.Boolean

IsPATCH

Indicates that request method id PATCH

Declaration
public bool IsPATCH { get; }
Property Value
Type Description
System.Boolean

IsPOST

Indicates that request method id POST

Declaration
public bool IsPOST { get; }
Property Value
Type Description
System.Boolean

IsPUT

Indicates that request method id PUT

Declaration
public bool IsPUT { get; }
Property Value
Type Description
System.Boolean

Items

Provides a thread-safe dictionary of items. The underlying collection is lazily allocated

Declaration
public ConcurrentDictionary<object, object> Items { get; }
Property Value
Type Description
System.Collections.Concurrent.ConcurrentDictionary<System.Object, System.Object>

LastError

Captures last error

Declaration
public Exception LastError { get; set; }
Property Value
Type Description
System.Exception

Match

Returns the work match instances that was made for this requested work or null if nothing was matched yet

Declaration
public WorkMatch Match { get; }
Property Value
Type Description
WorkMatch

Matched

Returns dynamic object that contains variables that have been extracted by WorkMatch when dispatcher assigned request to WorkHandler. If variables have not been assigned yet returns empty object

Declaration
public dynamic Matched { get; }
Property Value
Type Description
System.Object

MatchedVars

Returns variables that have been extracted by WorkMatch when dispatcher assigned request to WorkHandler. If variables have not been assigned yet returns empty object

Declaration
public JSONDataMap MatchedVars { get; }
Property Value
Type Description
JSONDataMap

NoDefaultAutoClose

Indicates whether the default dispatcher should close the WorkContext upon completion of async processing. This property may ONLY be set to TRUE IF Response.Buffered = false (chunked transfer) and Response has already been written to. When this property is set to true the WorkDispatcher will not auto dispose this WorkContext instance. This may be needed for a server that streams chat messages and some other thread manages the lifetime of this WorkContext. Keep in mind that alternative implementations of WorkDispatcher (derived classes that implement alternative threading/lifecycle) may disregard this flag altogether

Declaration
public bool NoDefaultAutoClose { get; set; }
Property Value
Type Description
System.Boolean

Portal

Returns portal object for this request or null if no portal was injected

Declaration
public Portal Portal { get; }
Property Value
Type Description
Portal

PortalFilter

Returns the first portal filter which was injected in the processing line. It is the filter that manages the portals for this context

Declaration
public PortalFilter PortalFilter { get; }
Property Value
Type Description
PortalFilter

PortalMatch

Returns matched that was made by portal filter or null

Declaration
public WorkMatch PortalMatch { get; }
Property Value
Type Description
WorkMatch

PortalMatchedVars

Returns variables that have been extracted by WorkMatch when PortalFilter assigned portal. Returns null if no portal was matched

Declaration
public JSONDataMap PortalMatchedVars { get; }
Property Value
Type Description
JSONDataMap

PortalTheme

Gets/sets portal theme. This may be null as this is just a holder variable

Declaration
public Theme PortalTheme { get; set; }
Property Value
Type Description
Theme

Request

Returns HttpListenerRequest object for this context

Declaration
public HttpListenerRequest Request { get; }
Property Value
Type Description
System.Net.HttpListenerRequest

RequestBodyAsJSONDataMap

Fetches request body: multipart content, url encoded content, or JSON body into one JSONDataMap bag, or null if there is no body. The property does caching

Declaration
public JSONDataMap RequestBodyAsJSONDataMap { get; }
Property Value
Type Description
JSONDataMap

RequestedJSON

Returns true if client indicated in response that "application/json" is accepted

Declaration
public bool RequestedJSON { get; }
Property Value
Type Description
System.Boolean

Response

Returns Response object for this context

Declaration
public Response Response { get; }
Property Value
Type Description
Response

Server

Returns the server this context is under

Declaration
public WaveServer Server { get; }
Property Value
Type Description
WaveServer

Session

Returns session that this context is linked with or null

Declaration
public WaveSession Session { get; }
Property Value
Type Description
WaveSession

SessionFilter

Returns the first session filter which was injected in the processing line. It is the filter that manages the session state for this context

Declaration
public SessionFilter SessionFilter { get; }
Property Value
Type Description
SessionFilter

SupportsSession

Returns true when the context was configured to support SessionFilter so Session can be injected

Declaration
public bool SupportsSession { get; }
Property Value
Type Description
System.Boolean

WholeRequestAsJSONDataMap

Fetches matched vars, multipart content, url encoded content, or JSON body into one JSONDataMap bag. The property does caching

Declaration
public JSONDataMap WholeRequestAsJSONDataMap { get; }
Property Value
Type Description
JSONDataMap

WorkSemaphoreReleased

Returns true to indicate that work semaphore has been already released. It is not necessary to use this property or ReleaseWorkSemaphore() method as the framework does it automatically in 99% cases. ReleaseWorkSemaphore() may need to be called from special places like HTTP streaming servers that need to keep WorkContext instances open for a long time

Declaration
public bool WorkSemaphoreReleased { get; }
Property Value
Type Description
System.Boolean

Methods

___InternalInjectPortal(Portal, Theme, WorkMatch, JSONDataMap)

DEVELOPERS do not use! A hack method needed in some VERY RARE cases, like serving an error page form the filter which is out of portal scope.

Declaration
public void ___InternalInjectPortal(Portal portal = null, Theme theme = null, WorkMatch match = null, JSONDataMap matchedVars = null)
Parameters
Type Name Description
Portal portal
Theme theme
WorkMatch match
JSONDataMap matchedVars

Destructor()

Warning: if overridden, must call base otherwise semaphore will not get released

Declaration
protected override void Destructor()
Overrides
DisposableObject.Destructor()

GetWholeRequestAsJSONDataMap()

Converts request body and MatchedVars into a single JSONDataMap. Users should call WholeRequestAsJSONDataMap.get() as it caches the result

Declaration
protected virtual JSONDataMap GetWholeRequestAsJSONDataMap()
Returns
Type Description
JSONDataMap

HasAnyVarsMatchingFieldNames(Row)

Returns true if the whole request (body or matched vars) contains any names matching any field names of the specified row

Declaration
public bool HasAnyVarsMatchingFieldNames(Row row)
Parameters
Type Name Description
Row row
Returns
Type Description
System.Boolean

Log(MessageType, String, String, Exception, String, Nullable<Guid>)

Facilitates context-aware logging

Declaration
public void Log(MessageType type, string text, string from = null, Exception error = null, string pars = null, Guid? related = default (Guid? ))
Parameters
Type Name Description
MessageType type
System.String text
System.String from
System.Exception error
System.String pars
System.Nullable<System.Guid> related

NeedsSession(Boolean)

Ensures that session is injected if session filter is present in processing chain. If session is already available (Session!=null) then does nothing, otherwise fills Session poroperty with either NEW session (if onlyExisting=false(default)) if user supplied no session token, OR gets session from session store as defined by the first SessionFilter in the chain

Declaration
public WaveSession NeedsSession(bool onlyExisting = false)
Parameters
Type Name Description
System.Boolean onlyExisting
Returns
Type Description
WaveSession

ParseRequestBodyAsJSONDataMap()

This method is called only once as it touches the input streams

Declaration
protected virtual JSONDataMap ParseRequestBodyAsJSONDataMap()
Returns
Type Description
JSONDataMap

ReleaseWorkSemaphore()

Releases work semaphore that throttles the processing of WorkContext instances. The WorkContext is released automatically in destructor, however there are cases when the semaphore release may be needed sooner, i.e. in a HTTP streaming application where work context instances are kept open indefinitely it may not be desirable to consider long-living work context instances as a throtteling factor. Returns true if semaphore was released, false if it was not released during this call as it was already released before

Declaration
public bool ReleaseWorkSemaphore()
Returns
Type Description
System.Boolean

SetAuthenticated(Boolean)

Invoked by applications to signify the presence of authentication

Declaration
public void SetAuthenticated(bool value)
Parameters
Type Name Description
System.Boolean value

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

Implements

System.IDisposable

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX