-
Notifications
You must be signed in to change notification settings - Fork 1
IServiceProvider Extensions
Set of extension methods for Microsoft.Xrm.Sdk.IServiceProvider base class. Just shortcut methods to save you few lines of code during plugin development.
Gets IPluginExecutionContext from service provider.
public IPluginExecutionContext GetPluginExecutionContext();
Gets IOrganizationServiceFactory from service provider.
public IOrganizationServiceFactory GetOrganizationServiceFactory();
Gets ITracingService extension from service provider.
public ITracingService GetTracingService();
Introduced in version 2.0.0
Gets PluginExecutionTraceContext from service provider.
public PluginExecutionTraceContext GetPluginExecutionTraceContext(PluginExecutionTraceContextSettings settings = null)
PluginExecutionTraceContext is a disposable wrapper around IPluginExecutionContext and ITracingService that simplifies tracing of plugin execution context properties in memory efficient way. Usage:
using (var traceContext = serviceProvider.GetPluginExecutionTraceContext()
{
traceContext.Trace("test message");
//by default we will trace only if error occurs
throw new InvalidPluginExecutionException();
}
Plugin trace log output will be similar to the following:
MessageName: "Create"
Stage: 0
PrimaryEntityId: "{GUID}"
PrimaryEntityName: "{entityName}"
serId: "{GUID}"
InitiatingUserId: "{GUID}"
Depth: 1
Mode: 0
test message
Real output will also include Input and Output parameters, Pre and Post Images and Shared Variables. You can also customize the behavior by passing PluginExecutionTraceContextSettings
into GetPluginExecutionTraceContext