本文整理汇总了C#中Cfg类的典型用法代码示例。如果您正苦于以下问题:C# Cfg类的具体用法?C# Cfg怎么用?C# Cfg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cfg类属于命名空间,在下文中一共展示了Cfg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadConfig
public static bool ReadConfig()
{
if (!Directory.Exists(savepath))
Directory.CreateDirectory(savepath);
if (!File.Exists(filepath))
{
try
{
CreateConfig();
}
catch
{
return false;
}
return true;
}
try
{
using (var sr = new StreamReader(filepath))
{
config = JsonConvert.DeserializeObject<Cfg>(sr.ReadToEnd());
}
}
catch (Exception ex)
{
Log.ConsoleError(ex.Message);
return false;
}
return true;
}
示例2: Configure
protected override void Configure(Cfg.Configuration configuration)
{
configuration.SetProperty(Cfg.Environment.BatchSize, "10");
configuration.SetProperty( Cfg.Environment.SqlExceptionConverter,
typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName);
}
示例3: SetupSqlServerOdbc
private static void SetupSqlServerOdbc(Cfg.Configuration cfg)
{
var connStr = cfg.Properties[Cfg.Environment.ConnectionString];
using (var conn = new OdbcConnection(connStr.Replace("Database=nhibernateOdbc", "Database=master")))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "drop database nhibernateOdbc";
try
{
cmd.ExecuteNonQuery();
}
catch(Exception e)
{
Console.WriteLine(e);
}
cmd.CommandText = "create database nhibernateOdbc";
cmd.ExecuteNonQuery();
}
}
}
示例4: Configure
protected override void Configure(Cfg.Configuration configuration)
{
if(Dialect is MsSql2000Dialect)
{
configuration.SetProperty(
Cfg.Environment.SqlExceptionConverter,
typeof(MSSQLExceptionConverterExample).AssemblyQualifiedName);
}
if (Dialect is Oracle8iDialect)
{
configuration.SetProperty(
Cfg.Environment.SqlExceptionConverter,
typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName);
}
if (Dialect is PostgreSQLDialect)
{
configuration.SetProperty(
Cfg.Environment.SqlExceptionConverter,
typeof(PostgresExceptionConverterExample).AssemblyQualifiedName);
}
if (Dialect is FirebirdDialect)
{
configuration.SetProperty(
Cfg.Environment.SqlExceptionConverter,
typeof(FbExceptionConverterExample).AssemblyQualifiedName);
}
}
示例5: Configure
//protected override bool AppliesTo(Dialect.Dialect dialect)
//{
// // this test work only with Field interception (NH-1618)
// return FieldInterceptionHelper.IsInstrumented( new Person() );
//}
protected override void Configure(Cfg.Configuration configuration)
{
configuration.SetProperty(Environment.ProxyFactoryFactoryClass,
typeof(NHibernate.ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName);
configuration.SetProperty(Environment.MaxFetchDepth, "2");
configuration.SetProperty(Environment.UseSecondLevelCache, "false");
}
示例6: Configure
protected override void Configure(Cfg.Configuration configuration)
{
configuration.Cache(x =>
{
x.Provider<HashtableCacheProvider>();
x.UseQueryCache = true;
});
}
示例7: AddMappings
protected override void AddMappings(Cfg.Configuration configuration)
{
// Set some properties that must be set before the mappings are added.
// (The overridable Configure(cfg) is called AFTER AddMappings(cfg).)
configuration.SetProperty(Cfg.Environment.PreferPooledValuesLo, _preferLo.ToString().ToLower());
base.AddMappings(configuration);
}
示例8: Configure
protected override void Configure(Cfg.Configuration configuration)
{
configuration.AddProperties(new Dictionary<string, string>
{
{
Cfg.Environment.QueryTranslator,
typeof (NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).FullName
}
}
);
}
示例9: Configure
protected override void Configure(Cfg.Configuration configuration)
{
var assembly = GetType().Assembly;
string mappingNamespace = GetType().Namespace;
foreach (var resource in assembly.GetManifestResourceNames())
{
if (resource.StartsWith(mappingNamespace) && resource.EndsWith(".hbm.xml"))
{
configuration.AddResource(resource, assembly);
}
}
}
示例10: getFor
public static AuditConfiguration getFor(Cfg.Configuration cfg) {
AuditConfiguration verCfg = null;
if(cfgs.Keys.Contains(cfg))
verCfg = cfgs[cfg];
else{
verCfg = new AuditConfiguration(cfg);
cfgs.Add(cfg, verCfg);
cfg.BuildMappings();
}
return verCfg;
}
示例11: Config
public void Config(IPersistenceUnitCfg puCfg, Cfg.Configuration configuration)
{
if(puCfg.Name == MockPersistenceUnitCfg.MockPUName )
{
configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
configuration.SetProperty("connection.connection_string", "Server=(local);initial catalog=NHibernateBurrow;Integrated Security=SSPI");
configuration.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
configuration.SetProperty("adonet.batch_size", testAdoBatchSize.ToString());
}
}
示例12: SetupFirebird
private static void SetupFirebird(Cfg.Configuration cfg)
{
try
{
if (File.Exists("NHibernate.fdb"))
File.Delete("NHibernate.fdb");
}
catch (Exception e)
{
Console.WriteLine(e);
}
FbConnection.CreateDatabase("Database=NHibernate.fdb;ServerType=1");
}
示例13: Load
private static void Load()
{
if (File.Exists(configName))
{
StreamReader sr = new StreamReader(configName);
cfg = (Cfg)jsonSerializer.Deserialize(sr, typeof(Cfg));
sr.Close();
}
else
{
cfg = new Cfg();
Save();
}
}
示例14: Configure
protected override void Configure(Cfg.Configuration configuration)
{
foreach (var cls in configuration.ClassMappings)
{
foreach (var prop in cls.PropertyIterator)
{
foreach (var col in prop.ColumnIterator)
{
if (col is Column)
{
var column = col as Column;
if (column.SqlType == "nvarchar(max)")
column.SqlType = Dialect.GetLongestTypeName(DbType.String);
}
}
}
}
}
示例15: SetupNpgsql
private static void SetupNpgsql(Cfg.Configuration cfg)
{
var connStr = cfg.Properties[Cfg.Environment.ConnectionString];
using (var conn = new NpgsqlConnection(connStr.Replace("Database=nhibernate", "Database=postgres")))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "drop database nhibernate";
try
{
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(e);
}
cmd.CommandText = "create database nhibernate";
cmd.ExecuteNonQuery();
}
}
// Install the GUID generator function that uses the most common "random" algorithm.
using (var conn = new NpgsqlConnection(connStr))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText =
@"CREATE OR REPLACE FUNCTION uuid_generate_v4()
RETURNS uuid
AS '$libdir/uuid-ossp', 'uuid_generate_v4'
VOLATILE STRICT LANGUAGE C;";
cmd.ExecuteNonQuery();
}
}
}