You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XrmPluginCore provides base functionality for developing plugins and custom APIs in Dynamics 365. It includes context wrappers and registration utilities to streamline the development process.
@@ -14,49 +14,82 @@ XrmPluginCore provides base functionality for developing plugins and custom APIs
14
14
### Creating a Plugin
15
15
16
16
1. Create a new class that inherits from `Plugin`.
17
-
2. Register the plugin using the `RegisterPlugin` helper methods.
17
+
2. Register the plugin using the `RegisterStep` helper method.
18
18
3. Implement the function in the custom action
19
19
20
-
#### Using the IServiceProvider wrapper
20
+
#### Using the a service
21
+
22
+
Create a service interface and concrete implementation:
**NOTE** It is recommended to use dependency injection based plugins instead of blindly using the IServiceProvider. See the example in [XrmBedrock](https://github.com/delegateas/XrmBedrock), or the sample plugin in the test project for more information.
68
+
Finally, create your plugin class that inherits from the base-plugin, and use dependency injection to get your service:
69
+
70
+
```csharp
71
+
usingSystem;
72
+
usingXrmFramework.BusinessDomain.ServiceContext;
73
+
usingXrmPluginCore;
74
+
usingXrmPluginCore.Enums;
75
+
76
+
namespaceSome.Namespace {
77
+
publicclassAccountChainPostPlugin : BasePlugin {
78
+
publicAccountChainPostPlugin() {
79
+
RegisterStep<Account, IMyService>(
80
+
EventOperation.Update,
81
+
ExecutionStage.PostOperation,
82
+
s=>s.DoSomething())
83
+
.AddFilteredAttributes(x=>x.Fax);
84
+
}
85
+
}
86
+
}
87
+
```
57
88
58
89
#### Using the LocalPluginContext wrapper
59
90
91
+
**NOTE**: This is only support to support legacy DAXIF/XrmFramework style plugins. It is recommended to use dependency injection based plugins instead.
92
+
60
93
```csharp
61
94
namespaceSome.Namespace {
62
95
usingSystem;
@@ -93,6 +126,27 @@ namespace Some.Namespace {
93
126
}
94
127
```
95
128
129
+
### Injected Services
130
+
The following services are available for injection into your plugin or custom API classes:
131
+
132
+
| Service | Description |
133
+
|---------|-------------|
134
+
|[IExtendedTracingService](XrmPluginCore/IExtendedTracingService.cs)| Extension to ITracingService with additional helper methods. |
135
+
|[ILogger 🔗](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/application-insights-ilogger)| The Plugin Telemetry Service logger interface. |
136
+
|[IOrganizationServiceFactory 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.iorganizationservicefactory)| Represents a factory for creating IOrganizationService instances. |
137
+
|[IPluginExecutionContext 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext)| The plugin execution context provides information about the current plugin execution, including input and output parameters, the message name, and the stage of execution. |
138
+
|[IPluginExecutionContext2 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext2)| Extension to IPluginExecutionContext with additional properties and methods. |
139
+
|[IPluginExecutionContext3 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext3)| Extension to IPluginExecutionContext2 with additional properties and methods. |
140
+
|[IPluginExecutionContext4 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext4)| Extension to IPluginExecutionContext3 with additional properties and methods. |
141
+
|[IPluginExecutionContext5 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext5)| Extension to IPluginExecutionContext4 with additional properties and methods. |
142
+
|[IPluginExecutionContext6 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext6)| Extension to IPluginExecutionContext5 with additional properties and methods. |
143
+
|[IPluginExecutionContext7 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.ipluginexecutioncontext7)| Extension to IPluginExecutionContext6 with additional properties and methods. |
144
+
|[ITracingService 🔗](https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.itracingservice)| The tracing service interface. The actual class is the [ExtendedTracingService](https://github.com/delegateas/XrmPluginCore/blob/main/XrmPluginCore/ExtendedTracingService.cs) wrapping the built-in `ITracingService`|
145
+
146
+
*Note:* Links marked with 🔗 point to official Microsoft documentation.
147
+
148
+
To register additional services, override the `OnBeforeBuildServiceProvider` method in your plugin or custom API class.
149
+
96
150
### Registering a Plugin
97
151
98
152
Use [XrmSync](https://github.com/delegateas/XrmSync) to automatically register relevant plugin steps and images.
0 commit comments