Plug-ins 101: Simplifying plug-in development – part 3

A short update of the progress I’m making…

At the moment I’m working on an abstraction layer to ease up the coding of plugins. Right now there are some hard nuts to crack.

Quiz_nutcracker

What have I done till now?

I implemented a base class that has a friendly set of virtual functions that you can override in your plugin class. Instead of having to work with message names and stages, you simply can call the function you need. The wiring on the background is done.

A typical plugin would look like this: lean and mean!

 

[code language=”javascript”]namespace JourneyIntoCRM.PluginBase
{
class TestPlugin: PluginBase
{
public override void OnPreCreate(IPluginExecutionContext context, IOrganizationService service)
{

}
}
}
[/code]

The idea is to have a set of virtual functions that you can override in your plugins. For now I’m planning to support the following functions:

[code language=”javascript”]public virtual void OnValidateCreate(IPluginExecutionContext context, IOrganizationService service) {}
public virtual void OnPreCreate(IPluginExecutionContext context, IOrganizationService service) {}
public virtual void OnPostCreate(IPluginExecutionContext context, IOrganizationService service) {}

public virtual void OnValidateUpdate(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPreUpdate(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPostUpdate(IPluginExecutionContext context, IOrganizationService service) { }

public virtual void OnValidateDelete(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPreDelete(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPostDelete(IPluginExecutionContext context, IOrganizationService service) { }

public virtual void OnPreRetrieve(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPostRetrieve(IPluginExecutionContext context, IOrganizationService service) { }

public virtual void OnPreRetrieveMultiple(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPostRetrieveMultiple(IPluginExecutionContext context, IOrganizationService service) { }

public virtual void OnValidateSetState(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPreSetState(IPluginExecutionContext context, IOrganizationService service) { }
public virtual void OnPostSetState(IPluginExecutionContext context, IOrganizationService service) { }

public virtual void OnExecute(IPluginExecutionContext context, IOrganizationService service) { }
[/code]

Unfortunately the hardest part has still to come.

I need to tackle a big technical hurdle which is the following:

The plugin registration tool sees my base class instead of my derived class. I need to hammer out some reflection code persuade the plugin registration tool to see my derived classes instead of my base class. Once I solved that puzzle in an elegant and understandable way, the code will be up this blog for download.

Not a task for the faint hearted   But nevertheless it has to be done.

Stay tuned!