Fabio, Thank-you.. that was very helpful.
A couple more follow-up questions. 1. If I were to implement like the blog link for multiple settings, how would I retrieve a particular one? (i.e. I would have configurations for SqlServer, MySql and SqlServerCE, for example. Based on the user's run-time connection settings, I would need to get the appropriate one) 2. Once connection settings are created by NhTestConfigurationProvider, how do you retrieve those settings externally? (i.e. I would like to use SchemaExport in an administrator page, etc for dropping or re-building the schema) 3. Is it possible to specify everything in the hibernate.cfg.xml in code rather than xml file? I still want the auto-mapping to happen, but would rather not be dependent on the xml file. Thanks again, Eric On Aug 26, 8:00 am, Fabio Maulo <[email protected]> wrote: > btw.. > only for ConnectionProvider you don't need something else > than DefaultSessionFactoryConfigurationProvider because > your ConnectionProvider can be injected using the default session-factory > configuration provided by NH. > > > > On Thu, Aug 26, 2010 at 9:56 AM, Fabio Maulo <[email protected]> wrote: > > LOL... uNhAddIns is fully designed using IoC (I don't mean a container but > > IoC) > > here is a blog post with some explications > > >http://fabiomaulo.blogspot.com/2009/09/configure-sessionfactory-provi... > > What you are looking for is IConfigurationProvider > > Let me show you a class I'm using for a test-suite... > > public class NhTestConfigurationProvider : > > DefaultSessionFactoryConfigurationProvider, IDisposable > > { > > private Configuration configuration; > > > public NhTestConfigurationProvider() > > { > > BeforeConfigure += ConfOrmConfigurationProviderBeforeConfigure; > > AfterConfigure += ValidateOrCreateSchema; > > } > > > #region IDisposable Members > > > public void Dispose() > > { > > var export = new SchemaExport(configuration); > > export.Drop(false, true); > > } > > > #endregion > > > private void ConfOrmConfigurationProviderBeforeConfigure(object sender, > > ConfiguringEventArgs e) > > { > > Configuration configuration = e.Configuration; > > configuration.Configure(); > > configuration.AddDeserializedMapping((new > > ConfOrmInitializer()).GetCompiledMappings(), "FullDomain"); > > e.Configured = true; > > } > > > private void ValidateOrCreateSchema(object sender, ConfigurationEventArgs > > e) > > { > > configuration = e.Configuration; > > var export = new SchemaExport(configuration); > > export.Drop(false, true); > > export.Create(false, true); > > } > > } > > > Here the setup of the test-suit > > [SetUpFixture] > > public class RetrieveTestContext > > { > > private WindsorContainer container; > > > [SetUp] > > public void Configure_NHibernate_and_ServiceLocator() > > { > > XmlConfigurator.Configure(new FileInfo("log4net.configuration.xml")); > > > container = new WindsorContainer(); > > container.Register(Component.For<IServiceLocator>() > > .Instance(new WindsorServiceLocator(container))); > > ServiceLocator.SetLocatorProvider(() => > > container.Resolve<IServiceLocator>()); > > > container.Register(Component.For<ISessionWrapper>() > > .ImplementedBy<FakeSessionWrapper>()); > > container.Register(Component.For<IConfigurationProvider>() > > .ImplementedBy<NhTestConfigurationProvider>()); > > container.Register(Component.For<ISessionFactoryProvider>() > > .ImplementedBy<SessionFactoryProvider>()); > > > try > > { > > container.Register(Component.For<ISessionFactory>() > > > .Instance(container.GetService<ISessionFactoryProvider>().GetFactory(null))); > > } > > catch (Exception e) > > { > > Console.WriteLine(e); > > throw; > > } > > > FillDb(container.GetService<ISessionFactoryProvider>().GetFactory(null)); > > } > > > On Thu, Aug 26, 2010 at 9:02 AM, Eric <[email protected]> wrote: > > >> Connection string is stored in custom DriverConnectionProvider > >> (i.e. <property > > >> name="connection.provider">Mandalore.Data.Impl.MyConnectionProvider,Mandalore.Data.Impl</ > >> property>) > > >> How do you manually initialize nhibernate using unhaddins? The process > >> "seems" out of my control right now... > > >> On Aug 26, 6:02 am, Jason Dentler <[email protected]> wrote: > >> > Where is your connection string stored? Why don't you validate it before > >> > initializing NHibernate? You can always do a quick, old fashioned > >> > ADO.NETconnection to test it first. > > >> > On Wed, Aug 25, 2010 at 5:09 PM, Eric <[email protected]> wrote: > > >> > > I am using my own DriverConnectionProvider and > >> > > proxyfactory.factory_class = ThreadLocalConversationalSessionContext > >> > > for a PC application. > > >> > > I would like to be able to disable the conversation (i.e. if user > >> > > connection settings are wrong), let the user change the connection > >> > > settings, hit connect, and let unhaddins and nhibernate do their > >> > > magic. > > >> > > Things do not seem quite happy to have an invalid connection string, > >> > > however. > >> > > Is there a way to disable conversations and cause a custom > >> > > DriverConnectionProvider to re-Configure? > > >> > > Best Regards, > >> > > Eric > > >> > > -- > >> > > 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]<nhusers%[email protected]> > >> <nhusers%[email protected]<nhusers%[email protected]> > > >> > > . > >> > > For more options, visit this group at > >> > >http://groups.google.com/group/nhusers?hl=en. > > >> -- > >> 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]<nhusers%[email protected]> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/nhusers?hl=en. > > > -- > > Fabio Maulo > > -- > Fabio Maulo -- 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.
