RDF - Object Mapping for RDF in .net

MakoLab open-source component

Configuring EntityContextFactory

Configuration API

The EntityContextFactoryClass comes with a number of methods, which are used to configure its behaviour. Previous pages have already shown the methods to configure entity mappings and define the meta graph URI.

1
2
3
4
5
6
var factory = new EntityContextFactory()
                  .WithMetaGraphUri(new Uri("http://example.org/graphs/"))
                  .WithMappings((MappingBuilder builder) =>
                                {
                                    builder.FromAssemblyOf<IPerson>();
                                });

TODO: describe the rest when API is final

Internal components

Internally Romantic Web uses an IoC container and most, if not all, components can be replaced. This is done by defining the components in a class derived from CompositionRootBase and registering that class with an entity context factory. Classes implementing CompositionRootBase may be internal but must declare public parameterless constructor. The base class exposes a number of methods, which change specific parts of Romantic Web.

1
2
3
4
5
6
7
8
public class MyComponents : CompositionRootBase
{
    public MyComponents()
    {
        BlankNodeIdGenerator<CustomGenerator>();
        NamedGraphSelector<CustomSelector>();
    }
}

It is also possible to register any custom component shall it be required. These components can be registered in a number of lifestyles:

  • shared - only one instance will ever be created
  • per-entity context - a new instance will be created for each CreateContext() call
  • transient - a new instance will be created every time it is requested
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class MyComponents : CompositionRootBase
{
    public MyComponents()
    {
        // shared registration by type
        SharedComponent<IShared, Shared>();

        // shared instance
        SharedComponent<IShared>(new Shared());

        // new instance for each `IEntityContext`
        PerEntityContextComponent<IScoped, Scoped>();

        // transient
        TransientComponent<ITransient, Transient>();
    }
}