SetString() public method

public SetString ( string name, string val ) : void
name string
val string
return void
示例#1
0
        /// <summary>
        /// 根据一个JSON来生成一个DataProvider
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static IDataProvider ParseProvider(String json)
        {
            Dictionary<String, String> dict = JsonConvert.DeserializeObject<Dictionary<String, String>>(json);

            BasicDataProvider provider = new BasicDataProvider();

            if (dict != null && dict.Count > 0)
            {
                foreach (var pair in dict)
                {
                    provider.SetString(pair.Key, pair.Value);
                }
            }

            return provider;
        }
示例#2
0
        public static BasicDataProvider CreateFromJson(String json)
        {
            BasicDataProvider provider = new BasicDataProvider();
            Dictionary<String, String> dict = JsonConvert.DeserializeObject<Dictionary<String, String>>(json);
            foreach (var pair in dict)
            {
                provider.SetString(pair.Key, pair.Value);
            }

            return provider;
        }
示例#3
0
        public static BasicDataProvider CreateFromXml(String xml)
        {
            BasicDataProvider provider = new BasicDataProvider();

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            XmlNodeList list = doc.SelectNodes(String.Format("/{0}/*", Constant.ParameterProviderNode));

            foreach (XmlNode node in list)
            {
                String name = node.Name;
                String val = node.InnerText.Trim();

                Int32 valInt;
                if (Int32.TryParse(val, out valInt))
                {
                    provider.SetInt(name, valInt);
                }
                else
                {
                    provider.SetString(name, val);
                }
            }

            return provider;
        }