Extensible Domain Model with NHibernate

I am currently developing a solution in which the domain model and repository can be extended with application plugins. Now I am faced with several problems that are listed below.

  • My first problem is to make the domain model extensible. I was thinking about using inheritance here, but to be honest, I have no idea how I can use multiple plugin modules that extend the same domain object. I seem to be inclined to make each domain object partial and allow plugins to extend it this way. In case I have several plugins that extend the same domain object, I do not have to worry about loading different extended domain assemblies for each plugin. I will still only have one federated domain object at runtime. Any ideas on this?

  • Another problem is the NHibernate mapping file extension. I could embed an embeddable domain object that it expands with each build file, and the NHibernate download manager loads it, rather than the one specified in the base domain. Once again, the problem is that if I have several plugins that extend the same domain object. I can have one plugin override file for another. The solution that I have in the last task is not so great, but I was thinking about including a checksum in the plugin assembly as a signature for the source mapping file that it used before distributing it. I can check this checksum at boot time and download the plugin map only if the checksums match. Pretty ugly, but at least I won’t redefine any cards,which are different from the base map used for expansion in the plugin assembly.

Anyway, I'd love to hear what you guys think about this. Thanks!

+3
source share
2 answers

The good news is that what you ask for is probably not that difficult to manage.

About plugin management, you can take a look at Microsoft Prism ( http://msdn.microsoft.com/fr-fr/magazine/cc785479.aspx ), which has some nice features for modular application development.

Example 1. You can match subclasses in separate mappings, in separate assemblies, look for NH documentation. A separate mapping file for the subclass is as follows:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <subclass name="YourClassFullName, YourPluginAssemblyName"
            extends="YourParentClassFullName, TheAssemblyWhereYourBaseClassIsDefined"
            discriminator-value="whateveryouwant">
    ... add your subclass mapping here ...
  </subclass>
</hibernate-mapping>

2. . (, IMappingLoader), ( ). NH Configuration. , Microsoft Prism IModule, Initialize() . IMappingLoader.

, .

0

, . / , .

, , Fluent NHibernate, .

, , DI . . , MEF , , .

0

Source: https://habr.com/ru/post/1715853/


All Articles