Exemplo n.º 1
0
        public void test()
        {
            Dictionary <string, object> a = new Dictionary <string, object>();

            a.Add("p:one", "p1");
            a.Add("p:two", "p2");
            a.Add("q:one", "q1");
            a.Add("q:two", "q2");

            object o = a["p:one"];
            var    k = a.Where(s => s.Key.Contains("p")).Select(d => d.Value);

            a.Remove("q:one");

            IStoreKeyValue store = StoreKeyValue.Instance;

            store.AddKeyValue("person", "id", "12003");
            store.AddKeyValue("person", "name", "prasanna");
            store.AddKeyValue("person", "email", "*****@*****.**");
            store.AddKeyValue("city", "name", "dubai");
            store.AddKeyValue("country", "name", "uae");
            store.AddKeyValue("test", "k1", "value01");
            store.AddKeyValue("test", "k2", "value02");
            store.AddKeyValue("test", "k3", "value03");

            var name = store.GetKeyValue("city", "name");

            store.DeleteKeyValue("test", "k1");

            var h = store.GetKeyValues("test");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save key value by namespace as group name
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        // PUT api/values/5
        public IHttpActionResult Put([FromBody] KeyValueModel value)
        {
            bool result = false;

            try
            {
                IStoreKeyValue store = StoreKeyValue.Instance;

                KeyValueModel copyOfKvp = value.Clone() as KeyValueModel;

                result = store.AddKeyValue(copyOfKvp._namespace, copyOfKvp.key, copyOfKvp.value);
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok());
        }