本文整理汇总了C#中KeyValue.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# KeyValue.ToString方法的具体用法?C# KeyValue.ToString怎么用?C# KeyValue.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateKV
static void generateKV() {
KeyValue root = new KeyValue("Dota2Functions");
string currClass = "Global";
foreach (var kv in funcs) {
kv.Value.processStats();
KeyValue func_kv = kv.Value.getKV();
root.AddChild(func_kv);
}
File.WriteAllText("d2functions.txt", root.ToString());
}
示例2: serializeSettings
public void serializeSettings()
{
KeyValue rootKV = new KeyValue("Addons");
foreach (KeyValuePair<string, Addon> a in addons) {
string addonName = a.Key;
Addon addon = a.Value;
KeyValue addonKV = new KeyValue(addonName);
addon.serializeSettings(addonKV);
rootKV.AddChild(addonKV);
}
// compress string to take up less space.
/*StringBuilder sb = new StringBuilder();
string[] split = rootKV.ToString().Split('\n');
for (int i = 0; i < split.Length; i++) {
string l = split[i];
l = l.Trim();
sb.AppendLine(l);
}*/
Settings.Default.AddonsKV = rootKV.ToString();
Settings.Default.Save();
}
示例3: serializeSettings
public void serializeSettings() {
var root = new KeyValue("InstalledAddons");
foreach (var kv in installedCustomGames) {
var cg = kv.Value;
cg.serializeSettings();
root.AddChild(cg.addonKV);
}
Settings.Default.InstalledAddonsKV = root.ToString();
Settings.Default.Save();
}
示例4: serializeSettings
public void serializeSettings() {
KeyValue rootKV = new KeyValue("Addons");
foreach (KeyValuePair<string, Addon> a in addons) {
string addonName = a.Key;
Addon addon = a.Value;
KeyValue addonKV = new KeyValue(addonName);
addon.serializeSettings(addonKV);
rootKV.AddChild(addonKV);
}
Settings.Default.AddonsKV = rootKV.ToString();
// serialize the customTiles
string customTilesSerialized = "";
for (int i = 0; i < customTiles.Length; i++) {
customTilesSerialized += customTiles[i].serializedTileInfo + "|";
}
Settings.Default.CustomTileInfo = customTilesSerialized;
Settings.Default.Save();
}
示例5: generateSoundMapFile
private void generateSoundMapFile() {
string[] files = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "*.txt", SearchOption.AllDirectories);
vsndToName = new Dictionary<string, List<string>>();
foreach (string file in files) {
try {
if (file.Contains("sounds") && !file.Contains("phonemes")) {
KeyValue[] roots = KVParser.KV1.ParseAll(File.ReadAllText(file));
if (roots == null || roots.Count() == 0) {
continue;
}
foreach (KeyValue kv2 in roots) {
string soundName = kv2.Key;
if (kv2.HasChildren) {
foreach (KeyValue kv3 in kv2.Children) {
if (kv3.Key.Contains("wave")) {
if (kv3.HasChildren) {
foreach (KeyValue kv4 in kv3.Children) {
string val4 = kv4.GetString();
if (val4.EndsWith(".wav") || val4.EndsWith(".mp3")) {
string vsnd = fixWave(val4);
//Debug.WriteLine(val4 + " | " + soundName);
string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
if (!vsndToName.ContainsKey(vsnd)) {
List<string> soundNames = new List<string>();
soundNames.Add(val);
vsndToName[vsnd] = soundNames;
} else {
if (!vsndToName[vsnd].Contains(val)) {
vsndToName[vsnd].Add(val);
}
}
}
}
} else {
string val3 = kv3.GetString();
if (val3.EndsWith(".wav") || val3.EndsWith(".mp3")) {
string vsnd = fixWave(val3);
//Debug.WriteLine(val3 + " | " + soundName);
string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
if (!vsndToName.ContainsKey(vsnd)) {
List<string> soundNames = new List<string>();
soundNames.Add(val);
vsndToName[vsnd] = soundNames;
} else {
if (!vsndToName[vsnd].Contains(val)) {
vsndToName[vsnd].Add(val);
}
}
}
}
}
}
}
}
}
} catch (Exception ex) {
Debug.WriteLine("Skipping " + file + ":");
//Debug.WriteLine(ex.ToString());
continue;
}
}
KeyValue root = new KeyValue("Sounds");
foreach (KeyValuePair<string, List<string>> m in vsndToName) {
string soundVsnd = m.Key;
List<string> soundInfos = m.Value;
KeyValue soundKV = new KeyValue(soundVsnd);
root.AddChild(soundKV);
foreach (string soundInfo in soundInfos) {
string[] parts = soundInfo.Split('|');
string soundName = parts[0];
string vsndevts = parts[1];
vsndevts = vsndevts.Replace("\\", "/");
vsndevts = vsndevts.Replace(".txt", ".vsndevts");
KeyValue waveKV = new KeyValue(soundName + "|" + vsndevts);
soundKV.AddChild(waveKV);
}
}
File.WriteAllText(vsnd_to_soundname_Path, root.ToString());
}