public void OnStartUp() { SetRootPathProject(); XmlTextReader configReader = new XmlTextReader(new MemoryStream(NHibernate.Test.Properties.Resources.Configuration)); DirectoryInfo dir = new DirectoryInfo(this.rootPathProject + ".Hbm"); Console.WriteLine(dir); builder = new NhConfigurationBuilder(configReader, dir); builder.SetProperty("connection.connection_string", GetConnectionString()); try { builder.BuildSessionFactory(); sessionFactory = builder.SessionFactory; } catch (Exception ex) { Console.WriteLine(ex); throw; } sessionProvider = new SessionManager(sessionFactory); currentPagedDAO = new EnterprisePagedDAO(sessionProvider); currentRootPagedDAO = new EnterpriseRootDAO<object>(sessionProvider); currentSession = sessionFactory.OpenSession(); }
static WcfServiceHolder() { string rootPath = HostingEnvironment.MapPath("~"); XmlTextReader configReader = new XmlTextReader(File.OpenRead(string.Format("{0}/cfg/Configuration.xml", rootPath))); DirectoryInfo dir = new DirectoryInfo(string.Format("{0}/hbm", rootPath)); NhConfigurationBuilder bld = new NhConfigurationBuilder(configReader, dir); bld.SetProperty("connection.connection_string", GetConnectionString(rootPath)); bld.BuildSessionFactory(); Sessionfactory = bld.SessionFactory; KnownTypes = Assembly.GetAssembly(typeof(Salesman)).GetTypes(); }