本文整理汇总了C#中KeyValue.Set方法的典型用法代码示例。如果您正苦于以下问题:C# KeyValue.Set方法的具体用法?C# KeyValue.Set怎么用?C# KeyValue.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getKV
public KeyValue getKV() {
KeyValue root = new KeyValue("Return Value");
KeyValue type = new KeyValue("Type");
type.Set(this.type);
KeyValue desc = new KeyValue("Description");
desc.Set(description);
root.AddChild(type);
root.AddChild(desc);
return root;
}
示例2: SaveToKV
public virtual KeyValue SaveToKV()
{
PropertyInfo[] properties = this.GetType().GetProperties();
KeyValue kv = new KeyValue(ClassName);
foreach (PropertyInfo info in properties)
{
//Don't want to write ClassName to the file since it's the key
if (info.Name == "ClassName") continue;
if (info.Name == "WasModified") continue;
object data = info.GetMethod.Invoke(this, new object[] { });
//If the value is default, skip it.
DefaultValueAttribute attib = info.GetCustomAttribute<DefaultValueAttribute>();
if ( attib != null && attib.Value == data) continue;
KeyValue subkey = new KeyValue(info.Name);
if (info.PropertyType == typeof(int))
{
subkey.Set((int)data);
}
if (info.PropertyType == typeof(float))
{
subkey.Set((float)data);
}
if (info.PropertyType == typeof(bool))
{
subkey.Set((bool)data);
}
if (info.PropertyType == typeof(string))
{
subkey.Set((string)data);
}
if (typeof(Enum).IsAssignableFrom(info.PropertyType))
{
subkey.Set(data.ToString().Replace(",", " |"));
}
if (info.PropertyType == typeof(PerLevel))
{
if (data == null) subkey.Set("");
else subkey.Set(((PerLevel)data).ToString());
}
kv += subkey;
}
return kv;
}
示例3: serializeSettings
internal void serializeSettings(KeyValue addonKV)
{
KeyValue workshopIDKV = new KeyValue("workshopID");
workshopIDKV.AddChild(new KeyValue(this.workshopID.ToString()));
addonKV.AddChild(workshopIDKV);
KeyValue generateNote0KV = new KeyValue("generateNote0");
generateNote0KV.AddChild(new KeyValue(this.generateNote0.ToString()));
addonKV.AddChild(generateNote0KV);
KeyValue generateLoreKV = new KeyValue("generateLore");
generateLoreKV.AddChild(new KeyValue(this.generateLore.ToString()));
addonKV.AddChild(generateLoreKV);
KeyValue askToBreakUp = new KeyValue("askToBreakUp");
askToBreakUp.AddChild(new KeyValue(this.askToBreakUp.ToString()));
addonKV.AddChild(askToBreakUp);
KeyValue autoDeleteBin = new KeyValue("autoDeleteBin");
autoDeleteBin.AddChild(new KeyValue(this.autoDeleteBin.ToString()));
addonKV.AddChild(autoDeleteBin);
KeyValue barebonesLibUpdates = new KeyValue("barebonesLibUpdates");
barebonesLibUpdates.AddChild(new KeyValue(this.barebonesLibUpdates.ToString()));
addonKV.AddChild(barebonesLibUpdates);
KeyValue generateUTF8 = new KeyValue("generateUTF8");
generateUTF8.AddChild(new KeyValue(this.generateUTF8.ToString()));
addonKV.AddChild(generateUTF8);
KeyValue libraries = new KeyValue("libraries");
addonKV.AddChild(libraries);
foreach (KeyValuePair<string, Library> libraryKV in this.libraries) {
Library lib = libraryKV.Value;
KeyValue libKV = new KeyValue(lib.local);
libraries.AddChild(libKV);
// populate libKV
if (lib.remote != null) {
KeyValue remoteKV = new KeyValue("Remote");
remoteKV.Set(lib.remote);
libKV.AddChild(remoteKV);
}
if (lib.defaultLibPath != null) {
KeyValue kv = new KeyValue("DefaultLibPath");
kv.Set(lib.defaultLibPath);
libKV.AddChild(kv);
}
var kv2 = new KeyValue("NeverCheckForUpdates");
kv2.Set(lib.neverCheckForUpdates);
libKV.AddChild(kv2);
}
}