代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.IO;
namespace MySqlDataBuild
{
public class Persist
{
private static Persist i;
public static Persist I
{
get
{
if (i == null)
{
i = new Persist();
LoadData(ref i);
}
return i;
}
}
public string version;
public string dbName;
internal string ip
{
get => this[dbName].ip;
set => this[dbName].ip = value;
}
internal string port
{
get => this[dbName].port;
set => this[dbName].port = value;
}
internal string pwd
{
get => this[dbName].pwd;
set => this[dbName].pwd = value;
}
internal string user
{
get => this[dbName].user;
set => this[dbName].user = value;
}
public string sqliteDBPath { get; set; }
public string sqliteGeneratePath { get; set; }
public int sqliteIncrementIdType { get; set; }
public int sqliteNamespaceIndex { get; set; }
internal int namespaceIndex
{
get => this[dbName].namespaceIndex;
set => this[dbName].namespaceIndex = value;
}
internal bool clearOldFiles
{
get => this[dbName].clearOldFiles;
set => this[dbName].clearOldFiles = value;
}
internal bool compatible
{
get => this[dbName].compatible;
set => this[dbName].compatible = value;
}
internal bool creatDbPath
{
get => this[dbName].creatDbPath;
set => this[dbName].creatDbPath = value;
}
internal int incrementIdType
{
get => this[dbName].incrementIdType;
set => this[dbName].incrementIdType = value;
}
internal int pathIndex
{
get => this[dbName].pathIndex;
set => this[dbName].pathIndex = value;
}
internal int exPathIndex
{
get => this[dbName].exIndex;
set => this[dbName].exIndex = value;
}
internal string path
{
get
{
if (string.IsNullOrEmpty(dbName))
return string.Empty;
if (datas.TryGetValue(dbName, out var data))
if (pathIndex != -1 & pathIndex < data.paths.Count)
return data.paths[pathIndex];
return string.Empty;
}
}
internal string exPath
{
get
{
if (string.IsNullOrEmpty(dbName))
return string.Empty;
if (datas.TryGetValue(dbName, out var data))
if (exPathIndex != -1 & exPathIndex < data.exPaths.Count)
return data.exPaths[exPathIndex];
return string.Empty;
}
}
internal List<string> paths
{
get => this[dbName].paths;
set => this[dbName].paths = value;
}
internal List<string> exPaths
{
get => this[dbName].exPaths;
set => this[dbName].exPaths = value;
}
public Dictionary<string, DataEntity> datas = new Dictionary<string, DataEntity>();
public DataEntity this[string name]
{
get
{
if (string.IsNullOrEmpty(dbName))
return new DataEntity();
if (datas.TryGetValue(dbName, out var data))
return data;
return new DataEntity();
}
}
public static void LoadData(ref Persist persist)
{
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "persist.data"))
return;
var jsonText = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "persist.data");
persist = Newtonsoft.Json.JsonConvert.DeserializeObject<Persist>(jsonText);
}
public static void SaveData()
{
var jsonText = Newtonsoft.Json.JsonConvert.SerializeObject(I);
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "persist.data", jsonText);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。