需要创建一个Visual Studio Project,plugin需要实现Microsoft.Xrm.Sdk.IPlugin接口
IPlugin中仅有一个Execute方法,从IServiceProvider中可以获取到 plug-in execution context (IPluginExecutionContext), tracing service (ITracingService), organization service (IOrganizationServiceFactory), and notification service (IServiceEndpointNotificationService)
namespace Microsoft.Xrm.Sdk
{
public interface IPlugin
{
//
// Summary:
// Executes plug-in code in response to an event.
//
// Parameters:
// serviceProvider:
// Type: IService_Provider. A container for service objects. Contains references
// to the plug-in execution context (Microsoft.Xrm.Sdk.IPluginExecutionContext),
// tracing service (Microsoft.Xrm.Sdk.ITracingService), organization service (Microsoft.Xrm.Sdk.IOrganizationServiceFactory),
// and notification service (Microsoft.Xrm.Sdk.IServiceEndpointNotificationService).
void Execute(IServiceProvider serviceProvider);
}
}
namespace System
{
public interface IServiceProvider
{
//
// Summary:
// Gets the service object of the specified type.
//
// Parameters:
// serviceType:
// An object that specifies the type of service object to get.
//
// Returns:
// A service object of type serviceType. -or- null if there is no service object
// of type serviceType.
object GetService(Type serviceType);
}
}
插件可以修改IPluginExecutionContext中的值。
IServiceEndpointNotificationService只提供一个功能,将当前entity发送到azure service bus。需要先注册Service Endpoint