示例#1
0
        /// <summary>
        /// 加载Xml
        /// </summary>
        /// <param name="path"></param>
        public static Propertys LoadXml(string xml)
        {
            Propertys res = new Propertys();

            res.propertyDict = new Dictionary <string, string>();
            XDocument xDoc = XDocument.Parse(xml);

            foreach (XElement ele in xDoc.Root.Elements())
            {
                if (res.propertyDict.ContainsKey(ele.Name.LocalName))
                {
                    Debug.unityLogger.LogError("Util", "键值重复:" + ele.Name.LocalName);
                }
                res.propertyDict.Add(ele.Name.LocalName, ele.Value);
            }
            return(res);
        }
示例#2
0
        /// <summary>
        /// 加载Json
        /// </summary>
        /// <param name="json"></param>
        public static Propertys LoadJson(string json)
        {
            Propertys res = new Propertys();

            res.propertyDict = new Dictionary <string, string>();
            JsonData data = new JsonData(json);

            foreach (string key in data.Keys)
            {
                if (res.propertyDict.ContainsKey(key))
                {
                    Debug.unityLogger.LogError("Util", "键值重复:" + key);
                }
                res.propertyDict.Add(key, data[key].ToString());
            }
            return(res);
        }
示例#3
0
        /// <summary>
        /// 加载属性并且加入
        /// </summary>
        /// <param name="name"></param>
        /// <param name="json"></param>
        public void LoadJsonProperty(string name, string json)
        {
            if (propertyDict.ContainsKey(name))
            {
                Debug.logger.LogError("Util", "不允许重复加载配置");
                return;
            }

            Propertys prop = Propertys.LoadJson(json);

            if (prop != null)
            {
                propertyDict.Add(name, prop);
            }
            else
            {
                Debug.logger.LogError("Util", "未能成功加载Property");
            }
        }