Esempio n. 1
0
    public void BuyResources(Dictionary <string, int> resources, City city)
    {
        JObject data = new JObject();

        data["city_id"]   = city.id;
        data["resources"] = JConstructor.FromObject(resources);
        Socket.Emit("buy_resources", data);
    }
Esempio n. 2
0
        public RequestParameters GetRequestParameters(string key, object value, Encoding encoding)
        {
            Dictionary <string, string[]> result = null;

            if (value != null)
            {
                var jt = JConstructor.FromObject(value);
                result = GetParameters(key, jt);
            }
            if (result == null)
            {
                result = new Dictionary <string, string[]>();
            }

            return(new RequestParameters(result, encoding));
        }
Esempio n. 3
0
        public RequestParameters GetRequestParameters(object value, Encoding encoding)
        {
            Dictionary <string, string[]> result = null;

            if (value != null)
            {
                var jt = JConstructor.FromObject(value) as JObject;
                if (jt == null)
                {
                    throw new Exception("只支持能转换为json的object对象的类型");
                }
                result = new Dictionary <string, string[]>();
                foreach (var item in jt)
                {
                    AddToDictionary(result, GetParameters(item.Key, item.Value));
                }
            }
            if (result == null)
            {
                result = new Dictionary <string, string[]>();
            }

            return(new RequestParameters(result, encoding));
        }