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


C# Configuration.GetProperty方法代码示例

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


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

示例1: CreateMapping

        public static ISearchMapping CreateMapping(Configuration cfg)
        {
            System.Type mappingClass = GetMappingClass(cfg.GetProperty(Environment.MappingClass));

            object instance;
            try
            {
                instance = Activator.CreateInstance(mappingClass);
            }
            catch (Exception ex)
            {
                throw new SearchException(
                    "Could not create search mapping class '" + mappingClass.FullName + "'.", ex
                );
            }

            if (!(instance is ISearchMapping))
            {
                throw new SearchException(string.Format(
                    "Search mapping class '{0}' does not implement '{1}'.",
                    mappingClass.FullName, typeof(ISearchMapping).FullName
                ));
            }

            return (ISearchMapping)instance;
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:26,代码来源:SearchMappingFactory.cs

示例2: Renderer

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="config"></param>
        protected Renderer(Configuration config)
		{
            _config = config;
			_dialect = Dialect.GetDialect(config.Properties);
            _defaultSchema = config.GetProperty(NHibernate.Cfg.Environment.DefaultSchema);

		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:11,代码来源:Renderer.cs

示例3: Configure

		protected override void Configure(Configuration configuration)
		{
			base.Configure(configuration);

			// Ugly hack.
			_OrignalDialectIsMsSql2005Dialect = Regex.IsMatch(configuration.GetProperty("dialect"), "MsSql200(5|8)Dialect");

			configuration.SetProperty("dialect", "NHibernate.Test.NHSpecificTest.NH1849.CustomDialect, NHibernate.Test");
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:9,代码来源:Fixture.cs

示例4: GenerateCreateScripts

		public string[] GenerateCreateScripts(Configuration config)
		{
			var defaultSchema = config.GetProperty(NHibernate.Cfg.Environment.DefaultSchema);
			var tableName = !string.IsNullOrEmpty(defaultSchema) ? defaultSchema + "." + _tableName : _tableName;

			return new[]
				{
					string.Format("create table {0} ( {1} {2} );", tableName, _columnName, DdlScriptGenerator.GetDialect(config).GetTypeName( NHibernate.SqlTypes.SqlTypeFactory.Int64 )),
					string.Format("insert into {0} values ( {1} )", tableName, _initialValue)
				};
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:11,代码来源:SequenceBroker.cs

示例5: Initialize

        public void Initialize(Configuration cfg)
        {
            searchFactory = SearchFactoryImpl.GetSearchFactory(cfg);
            string indexingStrategy = cfg.GetProperty(Environment.IndexingStrategy) ?? "event";

            if ("event".Equals(indexingStrategy))
            {
                used = searchFactory.DocumentBuilders.Count != 0;
            }
            else if ("manual".Equals(indexingStrategy))
            {
                used = false;
            }
            else
            {
                throw new SearchException(Environment.IndexBase + " unknown: " + indexingStrategy);
            }
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:18,代码来源:FullTextIndexEventListener.cs

示例6: InitSession

        /// <summary>
        /// Initialisieren der Session mit den Datenbanknamen.
        /// </summary>
        private void InitSession()
        {
            // KO-Kriterien zum Initialisieren ausschliessen
            if (!System.IO.File.Exists(_database)) throw new System.IO.FileNotFoundException("Datenbank existiert nicht");

            // Session initialisieren (Configuration, SessionFactory, Session)
            Configuration cfg = new NHibernate.Cfg.Configuration();
            cfg.Configure();
            // ConnectionString parsen und %dbname% ersetzen
            String connectionString = cfg.GetProperty("hibernate.connection.connection_string");
            connectionString = connectionString.Replace("%dbname%", _database);
            cfg.SetProperty("hibernate.connection.connection_string", connectionString);
            cfg.AddAssembly(System.Reflection.Assembly.GetExecutingAssembly());

            ISessionFactory factory = cfg.BuildSessionFactory();

            _session = factory.OpenSession();
            _session.FlushMode = FlushMode.Commit;
        }
开发者ID:BackupTheBerlios,项目名称:siesaso-svn,代码行数:22,代码来源:Session.cs

示例7: IsFor

        public bool IsFor(Configuration cfg) {
            var name = cfg.GetProperty(Environment.SessionFactoryName);
            using(var connection = myapp.ioc.get<IConnectionsSource>().Get(name).CreateConnection()) {
                try {
                    Console.WriteLine("try connection "+name+" for MAS");
                    connection.WellOpen();
                    var objid = connection.ExecuteScalar<int>("select object_id('mas.process')", (IParametersProvider)null);

                    var result = 0 != objid;
                    Console.WriteLine("connection " + name + "is for MAS: "+result);
                    return result;

                }catch(Exception ex) {
                    Console.WriteLine("connection " + name + "error: " + ex.Message);
                    return false;
                }
            }

        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:19,代码来源:MasModel.cs

示例8: EnsureCurrentVersion

        /// <summary>
        /// Runs the database upgrader
        /// </summary>
        /// <param name="scriptAssembly">The assembly containing the upgrade scripts</param>
        /// <param name="nhConfiguration">The NHibernate Configuration. The connection string must use a dbo user</param>
        public static int EnsureCurrentVersion(Assembly scriptAssembly, Configuration nhConfiguration)
        {
            var connectionString = nhConfiguration.GetProperty("connection.connection_string");

            var upgrader = new Upgrader(new ConnectionFactory(connectionString), new UpdateProvider(scriptAssembly), new DataInsertProvider(scriptAssembly));

            var oldVersion = upgrader.GetCurrentVersion();

            if (!oldVersion.HasValue)
            {
                upgrader.WipeDatabase();
                upgrader.CreateSchema(nhConfiguration);
                upgrader.RunInserts();
                return upgrader.SetLatestVersion();
            }
            else
            {
                return upgrader.RunUpdates(oldVersion.Value);
            }
        }
开发者ID:trullock,项目名称:MuonKit,代码行数:25,代码来源:Upgrader.cs

示例9: SetConnectionString

        public void SetConnectionString()
        {
            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            string shortConnectionString = @"%AppData%\Test\Test.data", expandedConnectionString = Environment.ExpandEnvironmentVariables(shortConnectionString);
            cfg.SetProperty(TestDataUtil.HibernateConnectionString, shortConnectionString);

            IDataBaseSetupImpl dataBaseSetup = new ProjectsRepository.DataBaseSetup(cfg);
            dataBaseSetup.ExpandEnvironmentVariablesInConnectionString();
            Assert.AreEqual(expandedConnectionString, cfg.GetProperty(TestDataUtil.HibernateConnectionString), "SetConnectionString doesn't expend environment variables properly.");
        }
开发者ID:ricardoborges,项目名称:NHibernate-Query-Analyzer,代码行数:10,代码来源:DataBaseSetupImplTests.cs

示例10: InitAnalyzer

        private static Analyzer InitAnalyzer(Configuration cfg)
        {
            System.Type analyzerClass;

            String analyzerClassName = cfg.GetProperty(Environment.AnalyzerClass);
            if (analyzerClassName != null)
                try
                {
                    analyzerClass = ReflectHelper.ClassForName(analyzerClassName);
                }
                catch (Exception e)
                {
                    throw new SearchException(
                        string.Format("Lucene analyzer class '{0}' defined in property '{1}' could not be found.",
                                      analyzerClassName, Environment.AnalyzerClass), e);
                }
            else
                analyzerClass = typeof(StandardAnalyzer);
            // Initialize analyzer
            Analyzer defaultAnalyzer;
            try
            {
                defaultAnalyzer = (Analyzer) Activator.CreateInstance(analyzerClass);
            }
            catch (InvalidCastException)
            {
                throw new SearchException(
                    string.Format("Lucene analyzer does not implement {0}: {1}", typeof(Analyzer).FullName,
                                  analyzerClassName)
                    );
            }
            catch (Exception)
            {
                throw new SearchException("Failed to instantiate lucene analyzer with type " + analyzerClassName);
            }
            return defaultAnalyzer;
        }
开发者ID:jrackley,项目名称:NHibernate-Search,代码行数:37,代码来源:SearchFactoryImpl.cs

示例11: GetConfiguration

        /// <summary>
        ///     Returns the NHibernate configuration for the specified connection alias.
        /// </summary>
        /// <param name="connectionAlias">The connection alias.</param>
        /// <returns>
        ///     NHibernate configuration
        /// </returns>
        public Configuration GetConfiguration(string connectionAlias)
        {
            var asm = GetAssemblyForResourceAssemblyName();
            var resourceName = GetResourceName();
            var cfg = new Configuration();
            cfg.Configure(asm, resourceName);
            if (string.Equals(cfg.GetProperty(Environment.SqlExceptionConverter),
                typeof (NHibernateSessionFactory).AssemblyQualifiedName))
            {
                cfg.SetProperty(
                    Environment.SqlExceptionConverter,
                    typeof (NHibernateSessionFactory).AssemblyQualifiedName);
            }

            SerializeDomainObjects(cfg);
            return cfg;
        }
开发者ID:phucls,项目名称:ara,代码行数:24,代码来源:NHibernateSessionFactory.cs


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