本文整理汇总了C#中Mono.Data.Sqlite.SqliteConnection.?.Close方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteConnection.?.Close方法的具体用法?C# SqliteConnection.?.Close怎么用?C# SqliteConnection.?.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.SqliteConnection
的用法示例。
在下文中一共展示了SqliteConnection.?.Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InfiniteChests_ChestDataImport
//.........这里部分代码省略.........
"Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
host[0],
host.Length == 1 ? "3306" : host[1],
TShock.Config.MySqlDbName,
TShock.Config.MySqlUsername,
TShock.Config.MySqlPassword
));
break;
case "sqlite":
dbConnection = new SqliteConnection(
string.Format("uri=file://{0},Version=3", sqliteDatabaseFilePath)
);
break;
default:
throw new NotImplementedException("Unsupported database.");
}
importedChests = 0;
overwrittenChests = 0;
protectFailures = 0;
using (QueryResult reader = dbConnection.QueryReader(
"SELECT X, Y, Account, Flags, Items FROM Chests WHERE WorldID = @0", Main.worldID)
) {
while (reader.Read()) {
int rawX = reader.Get<int>("X");
int rawY = reader.Get<int>("Y");
string rawAccount = reader.Get<string>("Account");
InfiniteChestsChestFlags rawFlags = (InfiniteChestsChestFlags)reader.Get<int>("Flags");
string rawItems = reader.Get<string>("Items");
if (!TerrariaUtils.Tiles.IsValidCoord(rawX, rawY))
continue;
DPoint chestLocation = new DPoint(rawX, rawY);
if (!TerrariaUtils.Tiles[chestLocation].active() || TerrariaUtils.Tiles[chestLocation].type != (int)BlockType.Chest) {
this.PluginTrace.WriteLineWarning(string.Format(
"The chest data on the location {0} could not be imported because no corresponding chest does exist in the world.",
chestLocation
));
continue;
}
// TSPlayer.All means that the chest must not be protected at all.
TSPlayer owner = TSPlayer.All;
if (!string.IsNullOrEmpty(rawAccount)) {
User tUser = TShock.Users.GetUserByName(rawAccount);
if (tUser != null) {
owner = new TSPlayer(0);
owner.User.ID = tUser.ID;
owner.User.Name = tUser.Name;
owner.Group = TShock.Groups.GetGroupByName(tUser.Group);
} else {
// The original owner of the chest does not exist anymore, so we just protect it for the server player.
owner = TSPlayer.Server;
}
}
int chestIndex = Chest.FindChest(rawX, rawY);
if (chestIndex == -1) {
chestIndex = Chest.CreateChest(rawX, rawY);
} else {
this.PluginTrace.WriteLineWarning(string.Format("The items of the chest {0} were overwritten.", chestLocation));
overwrittenChests++;
}
Chest tChest = Main.chest[chestIndex];
int[] itemArgs = new int[60];
string[] itemData = rawItems.Split(',');
for (int i = 0; i < 120; i++)
itemArgs[i] = int.Parse(itemData[i]);
for (int i = 0; i < 40; i++) {
tChest.item[i] = new Item();
tChest.item[i].netDefaults(itemArgs[i * 3]);
tChest.item[i].prefix = (byte)itemArgs[i * 3 + 2];
tChest.item[i].stack = itemArgs[i * 3 + 1];
}
importedChests++;
if (owner != TSPlayer.All) {
try {
ProtectionEntry protection = protectionManager.CreateProtection(owner, chestLocation, true, false, false);
protection.IsSharedWithEveryone = (rawFlags & InfiniteChestsChestFlags.PUBLIC) != 0;
if ((rawFlags & InfiniteChestsChestFlags.REFILL) != 0)
chestManager.SetUpRefillChest(owner, chestLocation, TimeSpan.Zero);
} catch (Exception ex) {
this.PluginTrace.WriteLineWarning(
"Failed to create protection or define refill chest at {0}:\n{1}", chestLocation, ex
);
protectFailures++;
}
}
}
}
} finally {
dbConnection?.Close();
}
}