For more information on the pipelines in Crm 2011, see here.
All good and fine so far, we have the ability in the SDK to see whether we are inside a Transaction or not via the IPluginExecutionContext (context.IsInTransaction).
My problem is a little more complex, I need to also know whether we are in the Pre-Event or Post-Event of the plugin. We sometimes need to check whether a plugin is a pre or post event plugin.
In Crm4.0 we simply used the IPluginExecutionContext (context.Stage), so:
if (context.Stage == MessageProcessingStage.BeforeMainOperationOutsideTransaction)
{ ... }
My problem is that I could not find how to do the equivalent in Crm 2011. The actual stage property is of type int, but normally the SDK would give us a static class or enumerator to use here. In Crm4.0 it was the MessageProcessingStage.
The actual integer values of the 5 possible states are published, so I simply added a static class to my helper methods to allow for this. I find it a little annoying that the Crm SDK forces you to use the integer value here when adding a simple enumerator to the SDK would be simple... but oh well.
No comments:
Post a Comment