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


C# Configuration.AddXmlString方法代码示例

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


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

示例1: WhenSubscribedToAfterBindThenRaiseEventForEachMapping

		public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping()
		{
			var listOfCalls = new List<BindMappingEventArgs>();
			var configuration = new Configuration();
			configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>());
			configuration.AfterBindMapping += (sender, args) => { Assert.That(sender, Is.SameAs(configuration)); listOfCalls.Add(args); };

			configuration.AddXmlString(ProductLineMapping);
			configuration.AddXmlString(ModelMapping);

			Assert.That(listOfCalls.Count, Is.EqualTo(2));
			Assert.That(listOfCalls.Select(x => x.FileName).All(x => x != null), Is.True);
			Assert.That(listOfCalls.Select(x => x.Mapping).All(x => x != null), Is.True);
			Assert.That(listOfCalls.Select(x => x.Dialect).All(x => x.GetType() == typeof(MsSql2008Dialect)), Is.True);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:15,代码来源:ConfigurationAddMappingEvents.cs

示例2: WhenSubscribedToAfterBindThenRaiseEventForEachMapping

		public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping()
		{
			var listOfCalls = new List<BindMappingEventArgs>();
			var configuration = new Configuration();
			configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>());
			configuration.AfterBindMapping += (sender, args) => { sender.Should().Be.SameInstanceAs(configuration); listOfCalls.Add(args); };

			configuration.AddXmlString(ProductLineMapping);
			configuration.AddXmlString(ModelMapping);

			listOfCalls.Count.Should().Be(2);
			listOfCalls.Select(x => x.FileName).All(x => x.Satisfy(filename => filename != null));
			listOfCalls.Select(x => x.Mapping).All(x => x.Satisfy(mappingDoc => mappingDoc != null));
			listOfCalls.Select(x => x.Dialect).All(x => x.Satisfy(dialect => dialect.GetType() == typeof(MsSql2008Dialect)));
		}
开发者ID:owerkop,项目名称:nhibernate-core,代码行数:15,代码来源:ConfigurationAddMappingEvents.cs

示例3: ExposeBug

		public void ExposeBug()
		{
	
			string hbm =
@"<?xml version='1.0' encoding='utf-8' ?> 
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'
								namespace='NHibernate.Test.NHSpecificTest.NH1290'
								assembly='NHibernate.Test'>
	<database-object>
		<definition class='AuxType'/>
	</database-object>
</hibernate-mapping>";

			Configuration cfg = new Configuration();
			cfg.AddXmlString(hbm);
			// the mapping is added without problem
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:17,代码来源:Fixture.cs

示例4: PersisterWithDefaultNamespaceAndAssembly

		public void PersisterWithDefaultNamespaceAndAssembly()
		{
			string hbm = @"<?xml version='1.0' encoding='utf-8' ?> 
							<hibernate-mapping xmlns='urn:nhibernate-mapping-2.0'
								namespace='NHibernate.DomainModel'
								assembly='NHibernate.DomainModel'>
								<class name='A' persister='A'>
									<id name='Id'>
										<generator class='native' />
									</id>
								</class>
							</hibernate-mapping>";

			Configuration cfg = new Configuration();
			cfg.AddXmlString( hbm );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:16,代码来源:ConfigurationFixture.cs

示例5: AddXmlString

		private static void AddXmlString(Configuration config, string xml, ActiveRecordModel model)
		{
			try
			{
				config.AddXmlString(xml);
			}
			catch(Exception ex)
			{
				throw new ActiveRecordException(
					"Error adding information from class " + model.Type.FullName +
					" to NHibernate. Check the inner exception for more information", ex);
			}
		}
开发者ID:joshrobb,项目名称:Castle.ActiveRecord,代码行数:13,代码来源:ActiveRecordStarter.cs

示例6: DisabledProxyValidator

		public void DisabledProxyValidator()
		{
			string hbm =
				@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
	<class name='NHibernate.DomainModel.NHSpecific.InvalidProxyClass, NHibernate.DomainModel'
		lazy='true'>
		<id name='Id' column='somecolumn'>
			<generator class='native' />
		</id>
	</class>
</hibernate-mapping>";

			Configuration cfg = new Configuration();
			cfg.Properties[Environment.UseProxyValidator] = "false";
			cfg.AddXmlString(hbm).BuildSessionFactory();
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:17,代码来源:ConfigurationFixture.cs

示例7: ProxyValidator

		public void ProxyValidator()
		{
			string hbm =
				@"<?xml version='1.0' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
	<class name='NHibernate.DomainModel.NHSpecific.InvalidProxyClass, NHibernate.DomainModel'
		lazy='true'>
		<id name='Id' column='somecolumn'>
			<generator class='native' />
		</id>
	</class>
</hibernate-mapping>";

			Configuration cfg = new Configuration();

			try
			{
				cfg.AddXmlString(hbm).BuildSessionFactory();
				Assert.Fail("Validation should have failed");
			}
			catch (MappingException e)
			{
				Assert.IsTrue(e is InvalidProxyTypeException);
			}
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:25,代码来源:ConfigurationFixture.cs

示例8: PrepareNHSessionFactory

        private ISessionFactory PrepareNHSessionFactory()
        {
            lock (_sessionFactoryLock)
            {
                if (_sessionFactory != null)
                    return _sessionFactory;

                var sw = Stopwatch.StartNew();

                var forceLoadObjectModel = _domainObjectModel.ObjectModel; // This is needed for "new Configuration()".
                var configuration = new Configuration();
                configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
                configuration.SetProperty("connection.connection_string", _connectionString);

                if (SqlUtility.DatabaseLanguage == "MsSql")
                {
                    configuration.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
                    configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
                }
                else if (SqlUtility.DatabaseLanguage == "Oracle")
                {
                    configuration.SetProperty("dialect", "NHibernate.Dialect.Oracle10gDialect");
                    configuration.SetProperty("connection.driver_class", "NHibernate.Driver.OracleDataClientDriver");
                }
                else
                    throw new FrameworkException(DatabaseLanguageError);

                ResolveEventHandler resolveAssembly = (s, args) => _domainObjectModel.ObjectModel;
                try
                {
                    AppDomain.CurrentDomain.AssemblyResolve += resolveAssembly;
                    configuration.AddXmlString(_nHibernateMapping.GetMapping());
                }
                finally
                {
                    AppDomain.CurrentDomain.AssemblyResolve -= resolveAssembly;
                }

                foreach (var configurationExtension in _nHibernateConfigurationExtensions)
                    configurationExtension.ExtendConfiguration(configuration);

                SchemaMetadataUpdater.QuoteTableAndColumns(configuration);
                var sessionFactory = configuration.BuildSessionFactory();

                _performanceLogger.Write(sw, "NHibernatePersistenceEngine.PrepareNHSessionFactory");
                return sessionFactory;
            }
        }
开发者ID:koav,项目名称:Rhetos,代码行数:48,代码来源:NHibernatePersistenceEngine.cs


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