• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# KeyValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中KeyValue的典型用法代码示例。如果您正苦于以下问题:C# KeyValue类的具体用法?C# KeyValue怎么用?C# KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KeyValue类属于命名空间,在下文中一共展示了KeyValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
                }
            }
        }
开发者ID:hex6,项目名称:WorldSmith,代码行数:25,代码来源:DotaAbilityParser.cs


示例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();
     }
 }
开发者ID:mrofferz,项目名称:mrofferz,代码行数:32,代码来源:Utility.cs


示例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;
 }
开发者ID:friuns,项目名称:New-Unity-Project-Eddy-Car-Phys,代码行数:7,代码来源:InputManager.cs


示例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());
        }
开发者ID:dhk-room101,项目名称:da2_toolset,代码行数:8,代码来源:GenericFile_Data.cs


示例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;
        }
开发者ID:hex6,项目名称:WorldSmith,代码行数:8,代码来源:BaseActionVariable.cs


示例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 });

            }
        }
开发者ID:hex6,项目名称:WorldSmith,代码行数:57,代码来源:DotaDataObject.cs


示例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;
			}
开发者ID:stephenfournier,项目名称:Dota2FunctionParser,代码行数:10,代码来源:D2Function.cs


示例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());
		}
开发者ID:stephenfournier,项目名称:Dota2FunctionParser,代码行数:10,代码来源:Program.cs


示例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();
        }
开发者ID:FreeApophis,项目名称:SQLiteMinimal,代码行数:10,代码来源:Program.cs


示例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;
        }
开发者ID:hex6,项目名称:WorldSmith,代码行数:11,代码来源:ActionCollection.cs


示例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;
        }
开发者ID:hex6,项目名称:WorldSmith,代码行数:11,代码来源:AbilityActionCollection.cs


示例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;
 }
开发者ID:friuns,项目名称:New-Unity-Project-tm2---Copy,代码行数:11,代码来源:InputManager.cs


示例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);
        }
开发者ID:gro-ove,项目名称:actools,代码行数:12,代码来源:LimitedStorage.cs


示例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);
     }
 }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:16,代码来源:KeyValueBuilder.cs


示例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;
        }
开发者ID:yuanrui,项目名称:Examples,代码行数:15,代码来源:GetOneElementDemo.cs


示例16: TestDeepCopy

        public void TestDeepCopy()
        {
            KeyValue kv = new KeyValue("Test");
            kv += new KeyValue("Key1") + "Some Value";
            kv += new KeyValue("Key2") + 3.14f;
            KeyValue child = new KeyValue("Child");
            child += new KeyValue("ChildKey") + true;
            kv += child;

            KeyValue clone = kv.Clone() as KeyValue;

            Assert.AreEqual("Test", clone.Key);
            Assert.AreEqual("Some Value", clone["Key1"].GetString());
            Assert.AreEqual("Child", clone["Child"].Key);
            Assert.AreEqual(true, clone["Child"]["ChildKey"].GetBool());
        }
开发者ID:GoeGaming,项目名称:KVLib,代码行数:16,代码来源:KeyValueTester.cs


示例17: GetErrorsFromModelState

        public static IEnumerable<KeyValue> GetErrorsFromModelState(ViewDataDictionary ViewData)
        {
            List<KeyValue> keyValue = new List<KeyValue>();

            foreach (var item in ViewData.ModelState)
            {
                if (item.Value.Errors.Any())
                {
                    KeyValue keyVal = new KeyValue();
                    keyVal.Key = item.Key;
                    keyVal.Value = item.Value.Errors[0].ErrorMessage;
                    keyValue.Add(keyVal);
                }
            }

            return keyValue;
        }
开发者ID:raj963,项目名称:NewClientOnBoarding,代码行数:17,代码来源:KeyValue.cs


示例18: Write

 public static void Write(
     Func<string> msgBuilder,
     LogLevel level,
     params KeyValue[] attrs)
 {
     KeyValue[] arr;
     if (attrs != null)
     {
         arr = new KeyValue[attrs.Length + 1];
         attrs.CopyTo(arr, 0);
         arr[arr.Length - 1] = new KeyValue { Key = key, Value = value };
     }
     else
     {
         arr = new[] { new KeyValue { Key = key, Value = value } };
     }
     Logger.Write(msgBuilder, level, arr);
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:18,代码来源:Logg.cs


示例19: Set

        public static void Set(string space, string key, string value) {
            KeysList l;
            if (!_instance._storage.TryGetValue(space, out l)) {
                throw new Exception("Unsupported space: " + space);
            }

            var i = l.FindIndex(x => x.Item1 == key);
            if (i != -1) {
                if (value == null) {
                    l.RemoveAt(i);
                } else {
                    l[i] = new KeyValue(key, value);
                }
            } else if (value != null){
                l.Enqueue(new KeyValue(key, value));
            }

            _instance.Save(space);
        }
开发者ID:gro-ove,项目名称:actools,代码行数:19,代码来源:LimitedStorage.cs


示例20: CreateNewAction

        public static BaseAction CreateNewAction(string name, KeyValue kv = null)
        {
            if (!FactoryDictionary.ContainsKey(name)) return null;

            Type actionType = FactoryDictionary[name];

            BaseAction action = null;

            if(kv == null)
            {
                action =  actionType.GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { name }) as BaseAction;
            }
            else
            {
                action =  actionType.GetConstructor(new Type[] { typeof(KeyValue) }).Invoke(new object[] { kv }) as BaseAction;
            }

            action.KeyValue.MakeEmptyParent();
            return action;
        }
开发者ID:Oplkill,项目名称:WorldSmith,代码行数:20,代码来源:DotaActionFactory.cs



注:本文中的KeyValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KeyValueDB类代码示例发布时间:2022-05-24
下一篇:
C# KeyType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap