本文整理汇总了C#中IDatabase.Load方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.Load方法的具体用法?C# IDatabase.Load怎么用?C# IDatabase.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.Load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init()
{
Version = new CVar("smod_version", "0.1");
// load plugins
Server.Print(License);
Server.RegisterCommand("smod", smod);
Verifier = new Verifier(Directory.GetCurrentDirectory(), Server.GameDirectory);
try {
var doc = new System.Xml.XmlDocument();
doc.Load(Path.Combine(Server.ModDirectory, Path.Combine("cfg", "databases.xml")));
try {
Database = DefaultDatabase.Load(Path.Combine(Server.ModDirectory, "SharpMod.Database.MySql.dll"));
Database.Load(doc);
} catch (Exception e) {
Server.LogError("Database Interface failed to load, using default: {0}", e.Message);
Database = new DefaultDatabase();
Database.Load(doc);
}
} catch (Exception e) {
Server.LogError("Failed to load cfg/databases.xml: {0}", e.Message);
}
Message.Init();
MapCycle.Init();
}
示例2: Load
private static void Load(IDatabase database, string xml)
{
var stringReader = new StringReader(xml);
var reader = new XmlTextReader(stringReader);
database.Load(reader);
reader.Close();
}
示例3: LoadDb
/// <summary>
/// Loads db, first from system, then from user.
/// Logs problems as warnings.
/// </summary>
private void LoadDb(IDatabase db, string path, bool reload, bool log = true)
{
var systemPath = Path.Combine("system", path).Replace('\\', '/');
var userPath = Path.Combine("user", path).Replace('\\', '/');
var cachePath = Path.Combine("cache", path).Replace('\\', '/');
cachePath = Path.ChangeExtension(cachePath, "mpk");
var cacheDir = Path.GetDirectoryName(cachePath);
if (!Directory.Exists(cacheDir))
Directory.CreateDirectory(cacheDir);
if (!File.Exists(systemPath))
throw new FileNotFoundException("Data file '" + systemPath + "' couldn't be found.", systemPath);
db.Load(new string[] { systemPath, userPath }, cachePath, reload);
foreach (var ex in db.Warnings)
Log.Warning("{0}", ex.ToString());
if (log)
Log.Info(" done loading {0} entries from {1}", db.Count, Path.GetFileName(path));
}
示例4: LoadDb
private static void LoadDb(IDatabase db, string path, bool reload, bool log = true)
{
db.Load(path, reload);
PrintDataWarnings(db.Warnings);
if (log)
Logger.Info("Done loading {0} entries from {1}.", db.Count, Path.GetFileName(path));
}
示例5: LoadDb
/// <summary>
/// Loads db, first from system, then from user.
/// Logs problems as warnings.
/// </summary>
private void LoadDb(IDatabase db, string path, bool reload, bool log = true)
{
var systemPath = Path.Combine("system", path);
var userPath = Path.Combine("user", path);
// System
{
db.Load(systemPath, reload);
foreach (var ex in db.Warnings)
Log.Warning(ex.ToString());
}
// User
{
// It's okay if user dbs don't exist.
if (File.Exists(userPath))
{
db.Load(userPath, false);
foreach (var ex in db.Warnings)
Log.Warning(ex.ToString());
}
}
if (log)
Log.Info(" done loading {0} entries from {1}", db.Count, Path.GetFileName(path));
}