The next version of Cuyahoga will use Castle to inject dependencies into modules. How does this affect persistent class registration in NHibernate? Is it done automatically? Are there other things we need to consider?
Many thanks
Simon
Ah yes, that's one of the advantages of the new version: you don't have to register module classes anymore. That's done automatically. You do have to mark the module controller with the INHibernateModule interface, otherwise the mappings are not added. You didn't need this at first, but then every module was added to the NHibernate configuration, even those that don't use NHibernate.
Check out the Downloads module in SVN for an example.
This probably means that all domain classes will have to live within the module assembly in order for them to be registered. What would happen if I had some other classes in a common assembly used by more than one module?
Many thanks
Simon
In one project, I have this same scenario. There is a central assembly that contains all domain logic that is used by multiple modules.
This central assembly has a static helper that registers all shared domain classes and returns a boolean to indicate if the sessionfactory was rebuilt:
base.SessionFactoryRebuilt = NHConfigHelper.RegisterCoreClasses();
instead of (Articles example)
SessionFactory sf = SessionFactory.GetInstance();
// Register classes that are used by the ArticleModule
sf.RegisterPersistentClass(typeof(Cuyahoga.Modules.Articles.Category));
sf.RegisterPersistentClass(typeof(Cuyahoga.Modules.Articles.Article));
sf.RegisterPersistentClass(typeof(Cuyahoga.Modules.Articles.Comment));
base.SessionFactoryRebuilt = sf.Rebuild();
...or alternatively I could add an assembly reference to facilities.config??
Of course, with the new infrastructure that's perfectly fine.