本文整理汇总了C#中NHibernate.Cfg.Configuration.AddXml方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddXml方法的具体用法?C# Configuration.AddXml怎么用?C# Configuration.AddXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.AddXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyConfiguration
/// <summary>
/// Adds mappings for this model to a NHibernate configuration object.
/// </summary>
/// <param name="configuration">A NHibernate configuration object to which to add mappings for this model.</param>
public static void ApplyConfiguration(Configuration configuration)
{
configuration.AddXml(Libro.MappingXml.ToString());
configuration.AddXml(Resenha.MappingXml.ToString());
configuration.AddXml(Autor.MappingXml.ToString());
configuration.AddAssembly(typeof(ConfigurationHelper).Assembly);
}
示例2: SetupContext
public void SetupContext()
{
// Setup "old" database schema
_cfg = new Configuration();
_cfg.Configure();
_cfg.AddXml(product_xml);
_cfg.AddXml(category_xml);
var export = new SchemaExport(_cfg);
export.Execute(false, true, false, false);
}
示例3: TestAccount
public static Boolean TestAccount(DatabaseAccountToken token, Boolean testMapping = false)
{
try
{
Configuration configuration = new Configuration();
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, token.ConnectionString);
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, String.Format("NHibernate.Driver.{0}", token.DatabaseDriver));
configuration.SetProperty(NHibernate.Cfg.Environment.Dialect, String.Format("NHibernate.Dialect.{0}", token.DatabaseDialect));
if (testMapping)
{
configuration.AddXml(token.Mapping);
using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
{
using (ISession session = sessionFactory.OpenSession())
{
return session.IsConnected;
}
}
}
else
{
using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
{
using (ISession session = sessionFactory.OpenSession())
{
return session.IsConnected;
}
}
}
}
catch (Exception ex)
{
return false;
}
}
示例4: Configure
protected override void Configure(Configuration configuration)
{
if (Dialect.Functions.ContainsKey("year"))
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NHibernate.Test.Component.Basic.User.hbm.xml"))
{
using (StreamReader reader = new StreamReader(stream))
{
string mapping = reader.ReadToEnd();
IList args = new ArrayList();
args.Add("dob");
// We don't have a session factory yet... is there some way to get one sooner?
string replacement = Dialect.Functions["year"].Render(args, null).ToString().Replace("\"", """);
mapping = mapping.Replace("year(dob)", replacement);
configuration.AddXml(mapping);
configuration.SetProperty(Cfg.Environment.GenerateStatistics, "true");
}
}
}
}
示例5: Add
public void Add(DatabaseAccountToken configFile)
{
try
{
if (sesionFactoryDictionary.ContainsKey(configFile.TokenId))
{
return;
}
else
{
Configuration configuration = new Configuration();
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, configFile.ConnectionString);
configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, String.Format("NHibernate.Driver.{0}", configFile.DatabaseDriver));
configuration.SetProperty(NHibernate.Cfg.Environment.Dialect, String.Format("NHibernate.Dialect.{0}", configFile.DatabaseDialect));
configuration.AddXml(configFile.Mapping);
sesionFactoryDictionary.Add(configFile.TokenId, configuration.BuildSessionFactory());
}
}
catch (Exception ex)
{
log.Error("Can't create sessionFactory", ex);
}
}
示例6: ApplyConfiguration
/// <summary>
/// Adds mappings for this model to a NHibernate configuration object.
/// </summary>
/// <param name="configuration">A NHibernate configuration object to which to add mappings for this model.</param>
public static void ApplyConfiguration(Configuration configuration)
{
configuration.AddXml(ModelMappingXml.ToString());
configuration.AddAssembly(typeof(ConfigurationHelper).Assembly);
}
示例7: NestedWithinGeneric
public void NestedWithinGeneric()
{
var configuration = new Configuration().Configure();
configuration.AddXml(string.Format(mappingTemplate, typeof(A<int>).FullName, typeof(A<int>.B).FullName));
}
示例8: ApplyConfiguration
/// <summary>
/// Adds mappings for this model to a NHibernate configuration object.
/// </summary>
/// <param name="configuration">A NHibernate configuration object to which to add mappings for this model.</param>
public static void ApplyConfiguration(Configuration configuration)
{
configuration.AddXml(ModelMappingXml.ToString());
configuration.AddXml(Grouping.MappingXml.ToString());
configuration.AddXml(Staff.MappingXml.ToString());
configuration.AddXml(GroupingType.MappingXml.ToString());
configuration.AddXml(Project.MappingXml.ToString());
configuration.AddXml(ProjectIssueSeverity.MappingXml.ToString());
configuration.AddXml(ProjectNotificationInstance.MappingXml.ToString());
configuration.AddXml(ProjectTask.MappingXml.ToString());
configuration.AddXml(ProjectTaskNotification.MappingXml.ToString());
configuration.AddXml(ProjectTaskType.MappingXml.ToString());
configuration.AddXml(ProjectType.MappingXml.ToString());
configuration.AddXml(ProjectUpdate.MappingXml.ToString());
configuration.AddXml(ProjectUpdateType.MappingXml.ToString());
configuration.AddXml(RequestForWork.MappingXml.ToString());
configuration.AddXml(ProjectNote.MappingXml.ToString());
configuration.AddXml(ProjectIssue.MappingXml.ToString());
configuration.AddXml(ProjectDocument.MappingXml.ToString());
configuration.AddAssembly(typeof(ConfigurationHelper).Assembly);
}
示例9: 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));
}
}
}