Welcome Guest, you are in: Login

dbones docs

RSS RSS

Navigation (boxes)




Search the wiki
»

Boxes Integration has areas where you can extend it, in this article we explore how.

Extending

Boxes Integration may not support everything you need, no worries, as you can extend it. A small internal container is used manage the contracts/services.

To add an extension all you have to do is:

  • Create an Extension point - there are some existing ones
  • Export the module in your package

Create Extension point

An extension is identified by types which implement the IBoxesExtension. These types are registered into the small internal container with the first interface they inherit.

An example is we want to add a custom process.

We start with the interface required in one of our modules:


public interface ILoadProcess<TBuilder, TContainer> : IBoxesExtension
{
    void LoadPackages(Application context, IEnumerable<string> packagesToEnable);
}

Once we have a contract we can implement it in either the same module, or another one (even a module in another package)


public class DefaultPackageLoader<TBuilder, TContainer> : ILoadProcess<TBuilder, TContainer>
{

    public DefaultPackageLoader(
        PackageRegistry packageRegistry,
        IIocFactory<TBuilder, TContainer> ioCFactory,
        IProcessOrder processOrder,
        IDefaultContainerSetup<TBuilder> containerSetup,
        ITrustManager trustManager)
    {
        //simple ctor injection support
    }

    //CODE...
}

We can inject any registered contract into our new extension.

NOTE: all instances are treated as singletons, and you can only have one type registered with a contract

Exporting the Extension

For Boxes Integration to find the extension we need to inform it via the package manifest.

using the http://schemas.dbones.co.uk/developer/boxes/2012/extension namespace, we can list which modules contain IBoxesExtensions.

Below is a sample:


<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns="http://schemas.dbones.co.uk/developer/boxes/2012/extension">
  <name>Process</name>
  <version>1.0.0</version>
  <description>Defines the Process interface and a default implementation</description>
  <exports>
    <assembly name="Process" /> <!--export it if it is referenced by the host app-->
  </exports>
  <imports>
    <dependency name="Identifiers" />
  </imports>
  <extends>
    <assembly name="Process" />
  </extends>
</manifest>

NOTE: you only need to Export a module when it is being referenced by the hosting application, we will see if we can fix that

dbones docs, is a sub-site of dbones.co.uk, all its content belongs to dbones.co.uk, this also includes logo's.