What I did, was making the singleton NHSessionManager class a service, by
removing it's singleton nature.
Then I created a virtual OnConfig() method, that allows me to change the
config in code, before creating the Session factory.
I expose the Configuration field as a property.
I subclassed NHSessionManager and overload the onconfig method.
I installed the Manager as a Service (as a lifecycle singleton) into my
container and have it injected into all Dao classes.
Works perfect and I actually got rid of one more of these pre DI hacks.
These days I tend more to the idea, that it is not the responisbility of a
class to consider, how it is exposed.
It´s much more natural for the container to have take care of a class'
singularity, than by the class itself.

Hope this helped (in the aftermath, probably you already resolved this by
now)

On Tue, Dec 2, 2008 at 11:34 AM, Tobes <[email protected]>wrote:

>
> I struggled with this a bit, and finally ended up doing this...
>
> Config File
> ========================================================
>
>  <session-factory>
>    <property
> name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
> property>
>    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</
> property>
>    <property
> name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
> property>
>    <property name="connection.connection_string">
>      Server=127.0.0.1;initial catalog=Blah;Integrated Security=SSPI
>    </property>
>    <property name="show_sql">false</property>
>    <property name="cache.use_second_level_cache">true</property>
>    <property name="cache.use_query_cache">true</property>
>
>        <!-- SEARCH CONFIG: DON'T WORK :( -->
>        <!--
>    <property name="hibernate.search.default.indexBase">c:\Code
> \Blah.com\App_Data\Lucene</property>
>    <property
>
> name="hibernate.search.default.directory_provider">NHibernate.Search.Storage.FSDirectoryProvider,
> NHibernate.Search</property>
>    -->
>    <mapping assembly="Blah.Data" />
>    <listener
>
> class="NHibernate.Search.Event.FullTextIndexEventListener,NHibernate.Search"
> type="post-insert"/>
>    <listener
>
> class="NHibernate.Search.Event.FullTextIndexEventListener,NHibernate.Search"
> type="post-update"/>
>    <listener
>
> class="NHibernate.Search.Event.FullTextIndexEventListener,NHibernate.Search"
> type="post-delete"/>
>  </session-factory>
>
> Global.asax.cs (Or wherever you start your app / create your session
> factory)
> ========================================================
>
> private void TweakConfigurationToAllowForLucene()
> {
>        var config = new Configuration();
>        config.AddProperties(new Dictionary<string, string>
>                                                         {
>
>
> {"hibernate.search.default.directory_provider","NHibernate.Search.Store.FSDirectoryProvider,
> NHibernate.Search"}
>
> ,{"hibernate.search.default.indexBase",@"C:\Code\Blah.com
> \App_Data\Lucene"}
>                                                     }
>                                                         });
>
>        config.Configure();
>        _factory = config.BuildSessionFactory();
> }
>
>
> I'm sure that there's a better way, but I ran out of time searching.
> This definately feels like a hack though - the config should just
> work. If I get time to look into it further I'll share on this thread.
>
> Tobin
>
>
> >
>


-- 
Jan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to