当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.AddProperties方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.AddProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddProperties方法的具体用法?C# Configuration.AddProperties怎么用?C# Configuration.AddProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.AddProperties方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCfg

        public global::NHibernate.Cfg.Configuration GetCfg(string[] addAssemblies)
        {
            SessionFactoryImpl sessionFactoryImpl = SpringHelper.ApplicationContext["NHibernateSessionFactory"] as SessionFactoryImpl;
            IDictionary springObjectDic = getSpringObjectPropertyValue("NHibernateSessionFactory", "HibernateProperties") as IDictionary;
            IDictionary<string, string> dic = new Dictionary<string, string>();
            foreach (DictionaryEntry de in springObjectDic)
            {
                dic.Add(de.Key.ToString(), de.Value.ToString());
                //if (de.Key.ToString().Equals("hibernate.dialect"))
                //{
                //    dialectName = de.Value.ToString();
                //}
            }

            #region //真正抓取設定檔的內容
            ISession session = sessionFactoryImpl.OpenSession();
            string connectionStr = session.Connection.ConnectionString;
            #endregion

            dic.Add("connection.connection_string", connectionStr);
            Configuration cfg = new Configuration();
            cfg.AddProperties(dic);

            foreach (string assembly in addAssemblies)
            {
                cfg.AddAssembly(assembly);
            }

            return cfg;
        }
开发者ID:dada2cindy,项目名称:my-case-petemobile,代码行数:30,代码来源:TestHelper.cs

示例2: Load

 protected override void Load(ContainerBuilder builder)
 {
     var cfg = new Configuration().Configure();
     cfg.AddProperties(new Dictionary<string, string>
                           {
                               {"current_session_context_class", "NHibernate.Context.WebSessionContext"}
                           });
     ISessionFactory sessionFactory = cfg.BuildSessionFactory();
     builder.RegisterInstance(sessionFactory);
     builder.RegisterType<NHibernateAmbientSessionManager>().AsSelf();
 }
开发者ID:pullpush,项目名称:NAd,代码行数:11,代码来源:NHibernateModule.cs

示例3: InitHibernate

 internal static void InitHibernate(string ConnectionString)
 {
     Console.WriteLine("Configuring Hibernate...");
     Configuration configuration = new Configuration();
     configuration.Configure();//預設抓目錄下的hibernate.cfg.xml
     configuration.AddAssembly(Assembly.GetCallingAssembly());
     configuration.AddProperties(new Dictionary<string, string>
                           {
                              {"connection.connection_string", ConnectionString}
                           });
     SessionFactory = configuration.BuildSessionFactory();
     Console.WriteLine("Created SessionFactory!");
 }
开发者ID:kinder5566,项目名称:VCKGoJapan,代码行数:13,代码来源:HibernateHelper.cs

示例4: MySessionSource

        public MySessionSource(IDictionary<string, string> properties, PersistenceModel model)
        {
            if(model == null) throw new ArgumentException("Model cannot be null!");

            _configuration = new Configuration();
            if (properties == null)
                _configuration.Configure();
            else
                _configuration.AddProperties(properties);

            Model = model;
            model.Configure(_configuration);

            _sessionFactory = _configuration.BuildSessionFactory();
        }
开发者ID:tasluk,项目名称:hibernatingrhinos,代码行数:15,代码来源:MySessionSource.cs

示例5: BuildSessionFactory

        public ISessionFactory BuildSessionFactory()
        {
            FileHelper.DeletePreviousDbFiles();
            var dbFile = FileHelper.GetDbFileName();
            var configuration = new Configuration();

            configuration.AddProperties(new Dictionary<string, string>
                                                {
                                                    { Environment.ConnectionString, string.Format("Data Source={0};Version=3;New=True;", dbFile) }
                                                });

            configuration.Configure();
            var schemaExport = new SchemaExport(configuration);
            schemaExport.Create(true, true);
            return configuration.BuildSessionFactory();
        }
开发者ID:kjellski,项目名称:nhibernatetraining,代码行数:16,代码来源:SQLiteHbmSessionFactoryBuilder.cs

示例6: FixtureSetup

        public void FixtureSetup()
        {
            BasicConfigurator.Configure();
            var cfg = new Configuration();
            cfg.AddProperties(new Dictionary<string, string> {
                {Environment.ConnectionProvider, typeof(DriverConnectionProvider).FullName},
                {Environment.Dialect, typeof(SQLiteDialect).FullName},
                {Environment.ConnectionDriver, typeof(SQLite20Driver).FullName},
                {Environment.ConnectionString, "Data Source=test.db;Version=3;New=True;"},
                //{"connection.release_mode", "on_close"},
            });

            cfg.AddClass(typeof (Simple));
            new SchemaExport(cfg).Create(true, true);
            sessionFactory = cfg.BuildSessionFactory();
        }
开发者ID:ruanzx,项目名称:mausch,代码行数:16,代码来源:SessionDirtyTests.cs

示例7: Open

    public void Open()
    {
      _database = new DatabaseManager();
      _database.Recreate();

      IDictionary<string, string> properties = SqlHelper.Provider.CreateNhibernateProperties();
      properties["connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
      properties["connection.connection_string"] = _database.Connection.ConnectionString;
      properties["connection.release_mode"] = "on_close";
      properties["proxyfactory.factory_class"] = "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle";

      Configuration configuration = new Configuration();
      configuration.AddProperties(properties);
      HbmSerializer.Default.Validate = true;
      MemoryStream stream = HbmSerializer.Default.Serialize(typeof(NorthwindEmployee).Assembly);
      stream.Position = 0;
      configuration.AddInputStream(stream);
      stream.Close();

      _sessionFactory = configuration.BuildSessionFactory();
    }
开发者ID:machine,项目名称:machine.uow,代码行数:21,代码来源:DatabaseAndNhSessionFactory.cs

示例8: InitializeNHibernateForBus

 private static void InitializeNHibernateForBus(IUnityContainer container)
 {
    Configuration cfg = new Configuration().Configure();
    cfg.AddProperties(new Dictionary<string, string>
                         {
                            {"current_session_context_class", "NHibernate.Context.ThreadStaticSessionContext"}
                         });
    ISessionFactory factory = cfg.BuildSessionFactory();
    container.RegisterInstance(factory);
 }
开发者ID:ssajous,项目名称:DDDSample.Net,代码行数:10,代码来源:Global.asax.cs

示例9: ExecuteTask

        /// <summary>
        /// Executes the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            Configuration config = new Configuration();
            Dictionary<string, string> properties = new Dictionary<string, string>();

            properties[NHibernate.Cfg.Environment.ConnectionProvider] = ConnectionProvider;
            properties[NHibernate.Cfg.Environment.Dialect] = Dialect;
            properties[NHibernate.Cfg.Environment.ConnectionDriver] = ConnectionDriverClass;
            properties[NHibernate.Cfg.Environment.ConnectionString] = ConnectionString;

            config.AddProperties(properties);

            foreach (string filename in Assemblies.FileNames)
            {
                Log(Level.Info, "Adding assembly file {0}", filename);
                try
                {
                    Assembly asm = Assembly.LoadFile(filename);
                    config.AddAssembly(asm);
                }
                catch (Exception e)
                {
                    Log(Level.Error, "Error loading assembly {0}: {1}", filename, e);
                }
            }

            SchemaExport se = new SchemaExport(config);
            if (!IsStringNullOrEmpty(OutputFilename))
            {
                se.SetOutputFile(OutputFilename);
            }
            se.SetDelimiter(Delimiter);
            Log(Level.Debug, "Exporting ddl schema.");
            se.Execute(OutputToConsole, ExportOnly, DropOnly, FormatNice);

            if (!IsStringNullOrEmpty(OutputFilename))
            {
                Log(Level.Info, "Successful DDL schema output: {0}", OutputFilename);
            }
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:43,代码来源:Hbm2DdlTask.cs

示例10: ConfigureNHibernate

        private static Configuration ConfigureNHibernate(string cfgFile, IDictionary<string, string> cfgProperties)
        {
            Configuration cfg = new Configuration();

            if (cfgProperties != null)
                cfg.AddProperties(cfgProperties);

            if (string.IsNullOrEmpty(cfgFile) == false)
                return cfg.Configure(cfgFile);

            if (File.Exists("Hibernate.cfg.xml"))
                return cfg.Configure();

            return cfg;
        }
开发者ID:klogeaage,项目名称:Sharp-Architecture,代码行数:15,代码来源:NHibernateSession.cs

示例11: RealEntities_Test

 public void RealEntities_Test()
 {
     var cfg = new Configuration();
     cfg.AddProperties(new Dictionary<string, string> {
         {Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider"},
         {Environment.Dialect, "NHibernate.Dialect.SQLiteDialect"},
         {Environment.ConnectionDriver, "NHibernate.Driver.SQLite20Driver"},
         {Environment.ConnectionString, "Data Source=test.db;Version=3;New=True;"},
     });
     cfg.AddXml(one_xml);
     cfg.AddXml(two_xml);
     cfg.AddXml(three_xml);
     new SchemaExport(cfg).Create(true, true);
     using (var factory = cfg.BuildSessionFactory()) {
         using (var session = factory.OpenSession()) {
             var three = new Three();
             session.Save(three);
             var two = new Two { Three = three };
             session.Save(two);
             session.Save(new One { Two = two });
             session.Flush();
         }
         using (var session = factory.OpenSession()) {
             var one = session.CreateCriteria(typeof (One)).List<One>()[0];
             Assert.IsFalse(NHibernateUtilEx.IsInitialized(() => one.Two));
             Assert.IsFalse(NHibernateUtilEx.IsInitialized(() => one.Two.Three));
             var t = one.Two.Three;
             Assert.IsTrue(NHibernateUtilEx.IsInitialized(() => one.Two));
             Assert.IsFalse(NHibernateUtilEx.IsInitialized(() => one.Two.Three));
         }
     }
 }
开发者ID:ruanzx,项目名称:mausch,代码行数:32,代码来源:ProxyTests.cs

示例12: InitializeNHibernate

      private void InitializeNHibernate()
      {         
         var cfg = new Configuration();
            cfg.AddProperties(new Dictionary<string, string>
                              {
                                 {Environment.ConnectionDriver, typeof (SQLite20Driver).FullName},
                                 {Environment.Dialect, typeof (SQLiteDialect).FullName},
                                 {Environment.ConnectionProvider, typeof (DriverConnectionProvider).FullName},
                                 {Environment.ConnectionString, "Data Source=:memory:;Version=3;New=True;"},
                                 {
                                    Environment.ProxyFactoryFactoryClass,
                                    typeof (ProxyFactoryFactory).AssemblyQualifiedName
                                    },
                                 {
                                    Environment.CurrentSessionContextClass,
                                    typeof (ThreadStaticSessionContext).AssemblyQualifiedName
                                    },
                                 {Environment.ReleaseConnections,"on_close"},
                                 {Environment.Hbm2ddlAuto, "create"},
                                 {Environment.ShowSql, true.ToString()}
                              });
         cfg.AddAssembly("DDDSample.DomainModel.Persistence");

         _sessionFactory = cfg.BuildSessionFactory();
         _ambientContainer.RegisterInstance(_sessionFactory);         

         ISession session = _sessionFactory.OpenSession();

         new SchemaExport(cfg).Execute(false, true, false, session.Connection, Console.Out);

         SampleLocations.CreateLocations(session);
         SampleTransportLegs.CreateTransportLegs(session);
         SampleVoyages.CreateVoyages(session);
         SampleCustomers.CreateCustomers(session);
         session.Flush();

         _currentSession = session;

         CurrentSessionContext.Bind(_currentSession);
      }
开发者ID:ssajous,项目名称:DDDSample.Net,代码行数:40,代码来源:ScenarioTest.cs

示例13: GetCfg

    private Configuration GetCfg()
    {
        SessionFactoryImpl s = (SessionFactoryImpl)ctx.GetObject("NHibernateSessionFactory");

        IResource resource = ctx.GetResource("file://~/App_Data/Dao.xml");
        IDictionary<string, string> dic = new Dictionary<string, string>();

        XmlDocument xdoc = new XmlDocument();
        xdoc.Load(resource.InputStream);

        XmlElement root = xdoc.DocumentElement;

        XmlNodeList nodeList = root.GetElementsByTagName("object");

        foreach (XmlNode node in nodeList)
        {
            if (node.Attributes["id"] != null && "NHibernateSessionFactory".Equals(node.Attributes["id"].Value))
            {
                XmlNodeList nodeList2 = node.ChildNodes[3].FirstChild.ChildNodes;

                foreach (XmlNode node2 in nodeList2)
                {
                    string key = node2.Attributes["key"].Value;
                    string value = node2.Attributes["value"].Value;
                    // log.Debug(key + ":" + value);
                    dic.Add(key, value);
                }
            }
        }

        XmlNode dbNode = root.GetElementsByTagName("db:provider")[0];
        string connectionStr = dbNode.Attributes["connectionString"].Value;

        dic.Add("connection.connection_string", connectionStr);
        Configuration cfg = new Configuration();
        cfg.AddProperties(dic);

        foreach (string assem in ASSEMBLES)
        {
            cfg.AddAssembly(assem);
        }

        return cfg;
    }
开发者ID:dada2cindy,项目名称:wudada-eip,代码行数:44,代码来源:schema.aspx.cs


注:本文中的NHibernate.Cfg.Configuration.AddProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。