Table of Contents

Class EventContext

Namespace
Hsl.Xrm.Sdk.Plugin
Assembly
Hsl.Xrm.Sdk.Plugin.dll
public abstract class EventContext : IEventContext
Inheritance
EventContext
Implements
Derived
Inherited Members

Constructors

EventContext()

public EventContext()

Fields

NoContextWithoutServiceProvider

protected static readonly string NoContextWithoutServiceProvider

Field Value

string

NoOrgServiceFactoryWithoutServiceProvider

protected static readonly string NoOrgServiceFactoryWithoutServiceProvider

Field Value

string

NoTracingServiceWithoutServiceProvider

protected static readonly string NoTracingServiceWithoutServiceProvider

Field Value

string

Properties

ActionTypeName

public string ActionTypeName { get; protected set; }

Property Value

string

ExecutionContext

Gets the execution context for the event execution instance.

public IExecutionContext ExecutionContext { get; }

Property Value

IExecutionContext

InitiatingUserOrgService

Gets an organization service using the initiating user's context.

protected IOrganizationService InitiatingUserOrgService { get; }

Property Value

IOrganizationService

IsExecutingAsynchronously

Indicates if executing asynchronously.

public bool IsExecutingAsynchronously { get; }

Property Value

bool

IsExecutingInSandbox

Indicates if executing in Sandbox isolation mode.

public bool IsExecutingInSandbox { get; }

Property Value

bool

IsExecutingSynchronously

Indicates if executing synchronously.

public bool IsExecutingSynchronously { get; }

Property Value

bool

SystemOrgService

Gets an organization service using the system user's context.

protected IOrganizationService SystemOrgService { get; }

Property Value

IOrganizationService

TracingService

Gets the Tracing service from the plugin context.

public ITracingService TracingService { get; }

Property Value

ITracingService

UserOrgService

Gets an organization service using the user's context.

protected IOrganizationService UserOrgService { get; }

Property Value

IOrganizationService

XrmContext

public IXrmContext XrmContext { get; protected set; }

Property Value

IXrmContext

Methods

Assert(bool, string, params object[])

Asserts the specified condition by throwing an InvalidPluginExecutionException if the condition is false.

public void Assert(bool condition, string message, params object[] args)

Parameters

condition bool

The condition to assert.

message string

The message for the exception.

args object[]

Arguments used for substituion into the placeholders contained in the message.

BuildInnerException(Exception)

public Exception? BuildInnerException(Exception ex)

Parameters

ex Exception

Returns

Exception

CanSendException(Exception)

Whether the Exception can be sent/deserialized.

public bool CanSendException(Exception ex)

Parameters

ex Exception

Returns

bool

GetExecutionContext()

protected abstract IExecutionContext GetExecutionContext()

Returns

IExecutionContext

GetOrgService(Guid?)

Gets an organization service using the specified user.

public IOrganizationService GetOrgService(Guid? userId)

Parameters

userId Guid?

Specifies the user context for the OrganizationService that is retrieved. A null value indicates the SYSTEM user. A Guid.Empty value indicates the same user a IExecutionContext.UserId Any other value indicates a specific user.

Returns

IOrganizationService

GetOrganizationServiceFactory()

protected abstract IOrganizationServiceFactory GetOrganizationServiceFactory()

Returns

IOrganizationServiceFactory

GetParentContext(IExecutionContext)

protected abstract IExecutionContext? GetParentContext(IExecutionContext ctx)

Parameters

ctx IExecutionContext

Returns

IExecutionContext

GetTracingService()

protected abstract ITracingService GetTracingService()

Returns

ITracingService

Throw(string, Exception?, params object[])

Throws an InvalidPluginExecutionException with the specified message and inner exception.

public void Throw(string message, Exception? inner, params object[] args)

Parameters

message string

The message for the exception.

inner Exception

The inner exception.

args object[]

Arguments used for substitution into the placeholders contains in the message.

Trace(string, params object[])

Traces data to the tracing service if it is available.

public virtual void Trace(string message, params object[] args)

Parameters

message string
args object[]

TraceException(string, Exception, params object[])

Traces an Exception with the specified message.

public void TraceException(string message, Exception ex, params object[] args)

Parameters

message string

The message for the exception.

ex Exception

The exception.

args object[]

Arguments used for substitution into the placeholders contains in the message.