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