本文整理汇总了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);
}
示例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)));
}
示例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
}
示例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 );
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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;
}
}