本文整理汇总了C#中KeyValue类的典型用法代码示例。如果您正苦于以下问题:C# KeyValue类的具体用法?C# KeyValue怎么用?C# KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyValue类属于命名空间,在下文中一共展示了KeyValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFromKeyValues
public override void LoadFromKeyValues(KeyValue kv)
{
base.LoadFromKeyValues(kv);
ActionList = new AbilityActionCollection();
foreach(string key in ActionList.Actions.Keys)
{
KeyValue kvActions = kv[key];
if (kvActions == null) continue; //We don't have any actions there so skip
foreach(KeyValue actionChild in kvActions.Children)
{
if (!actionChild.HasChildren) continue; //TODO: Handle the Dontdestroy key
BaseAction action = DotaActionFactory.CreateNewAction(actionChild.Key);
if(action == null)
{
MessageBox.Show("WARNING: Action " + actionChild.Key + " not found in factory when creating ability: " + this.ClassName, "Loading Warning", MessageBoxButtons.OK);
continue;
}
action.LoadFromKeyValues(actionChild);
ActionList.Actions[key].Add(action);
}
}
}
示例2: AppendQueryString
/// <summary>
/// Appends a parameter to the given url as a query string
/// </summary>
/// <param name="path">url</param>
/// <param name="queryStringParameter">parameter to append</param>
/// <returns>url appended with the query string</returns>
public static string AppendQueryString(string path, KeyValue queryStringParameter)
{
if (!string.IsNullOrEmpty(path) && queryStringParameter != null)
{
if (path.Contains(CommonStrings.QuestionSymbol.ToString()))
{
return (string.Concat(path,
CommonStrings.AndSymbol,
queryStringParameter.Key,
CommonStrings.EqualSymbol,
Convert.ToString(queryStringParameter.Value)));
}
else
{
return (string.Concat(path,
CommonStrings.QuestionSymbol,
queryStringParameter.Key,
CommonStrings.EqualSymbol,
Convert.ToString(queryStringParameter.Value)));
}
}
else
{
throw new ArgumentException();
}
}
示例3: Add
public void Add(KeyCode key, string descr, KeyCode alt = KeyCode.None)
{
var keyValue = new KeyValue() { descr = descr, keyCodeAlt = new[] { key, alt }, main = key };
keyValue.Load();
keys.Add(keyValue);
m_alternatives[(int)key] = keyValue;
}
示例4: Import
public void Import(KeyValue root)
{
this.Data = new MemoryStream();
this.FileVersion = 0;
long newOffset = this.Structures[0].DataSize;
this.ImportStructure(this.Structures[0], root, 0, ref newOffset, new ImportState());
}
示例5: ToKV
public KeyValue ToKV(string key)
{
KeyValue parent = new KeyValue(key);
parent += new KeyValue("var_type") + Type.ToString();
parent += new KeyValue(Name) + DefaultValue;
return parent;
}
示例6: LoadFromKeyValues
public virtual void LoadFromKeyValues(KeyValue kv)
{
PropertyInfo[] properties = this.GetType().GetProperties();
ClassName = kv.Key;
foreach(PropertyInfo info in properties)
{
if (info.Name == "ClassName") continue;
if (info.Name == "WasModified") continue;
KeyValue subkey = kv[info.Name];
if (subkey == null)
{
continue;
}
if (subkey.HasChildren) continue; //TODO parse children because this is AbilitySpecial
object data = null;
if(info.PropertyType == typeof(int))
{
data = subkey.GetInt();
}
if(info.PropertyType == typeof(float))
{
data = subkey.GetFloat();
}
if(info.PropertyType == typeof(bool))
{
data = subkey.GetBool();
}
if(info.PropertyType == typeof(string))
{
data = subkey.GetString();
}
if (typeof(Enum).IsAssignableFrom(info.PropertyType) && subkey.GetString() != "")
{
if (info.PropertyType.GetCustomAttribute(typeof(FlagsAttribute)) != null)
{
string[] flags = subkey.GetString().Replace(" ", "").Split('|').Where(x => x != "").ToArray();
string p = String.Join(", ", flags);
data = Enum.Parse(info.PropertyType, p);
}
else
{
data = Enum.Parse(info.PropertyType, subkey.GetString());
}
}
if (info.PropertyType == typeof(PerLevel))
{
data = new PerLevel(subkey.GetString().Trim());
}
if(data != null) info.SetMethod.Invoke(this, new object[] { data });
}
}
示例7: 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;
}
示例8: 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());
}
示例9: Main
static void Main()
{
var value = new KeyValue { Key = "Key1", Value = "Value1" };
Db.Main.KeyValues.InsertOnSubmit(value);
Db.Main.SubmitChanges();
System.Console.WriteLine(Db.Main.KeyValues.Where(p => p.Key == "Key1").Count());
System.Console.ReadLine();
}
示例10: ToKV
public KeyValue ToKV(string Key)
{
KeyValue doc = new KeyValue(Key);
foreach(BaseAction action in this.List.Cast<BaseAction>())
{
KeyValue child = new KeyValue(action.ClassName);
doc += action.SaveToKV();
}
return doc;
}
示例11: ToKV
public KeyValue ToKV()
{
KeyValue kv = new KeyValue("Actions");
foreach (KeyValuePair<string, ActionCollection> k in Actions)
{
KeyValue child = k.Value.ToKV(k.Key);
kv += child;
}
return kv;
}
示例12: Add
public void Add(KeyCode key, string descr, params KeyCode[] alt)
{
var l = new List<KeyCode>(alt.Take(1));
l.Insert(0, key);
foreach (KeyCode a in l)
KeyBack[a] = key;
var keyValue = new KeyValue() { descr = descr, keyCodeAlt = l.ToArray(), main = key };
keyValue.Load();
keys.Add(keyValue);
m_alternatives[(int)key] = keyValue;
}
示例13: Move
public static void Move(string space, string oldKey, string newKey) {
KeysList l;
if (!_instance._storage.TryGetValue(space, out l)) {
throw new Exception("Unsupported space: " + space);
}
var i = l.FindIndex(x => x.Item1 == oldKey);
if (i == -1) return;
l[i] = new KeyValue(newKey, l[i].Item2);
_instance.Save(space);
}
示例14: KeyValueBuilder
/// <summary>
///
/// </summary>
/// <param name="kvs"></param>
public KeyValueBuilder(Dictionary<string, string> kvs)
{
if (kvs == null)
{
throw new ArgumentNullException();
}
foreach (var item in kvs)
{
var infoValue = new KeyValue {Key = item.Key, Value = item.Value};
_list.Add(infoValue);
}
}
示例15: BuildUniqueSources
private static IEnumerable<KeyValue> BuildUniqueSources()
{
var result = new List<KeyValue>();
for (int i = 0; i < 10000; i++)
{
for (int j = 65; j < 91; j++)
{
var obj = new KeyValue() { Key = string.Format("{0}{0}{0}-{1}", (char)j, i), Value = i };
result.Add(obj);
}
}
return result;
}