Esempio n. 1
0
        private static void UpdateDict(PBXPlistDict dict, PBXPlistDict config)
        {
            foreach (var pair in config)
            {
                if (!dict.ContainsKey(pair.Key))
                {
                    dict.Add(pair.Key, pair.Value);
                }
                else
                {
                    var dictVal       = dict[pair.Key];
                    var dictConfigVal = pair.Value;

                    if (dictVal is ArrayList)
                    {
                        UpdateArray((ArrayList)dictVal, (ArrayList)dictConfigVal);
                    }
                    else if (dictVal is PBXPlistDict)
                    {
                        UpdateDict((PBXPlistDict)dictVal, (PBXPlistDict)dictConfigVal);
                    }
                    else
                    {
                        dictVal = dictConfigVal;
                    }
                }
            }
        }
Esempio n. 2
0
 private void ParseDictForLoad(PBXPlistDict dict, IEnumerable <XElement> elements)
 {
     for (int i = 0; i < elements.Count(); i += 2)
     {
         XElement key = elements.ElementAt(i);
         XElement val = elements.ElementAt(i + 1);
         dict[key.Value] = ParseValueForLoad(val);
     }
 }
Esempio n. 3
0
        private XElement ParseDictForSave(PBXPlistDict dict)
        {
            XElement dictNode = new XElement(TYPE_DICT);

            foreach (string key in dict.Keys)
            {
                dictNode.Add(new XElement(TYPE_KEY, key));
                dictNode.Add(ParseValueForSave(dict[key]));
            }
            return(dictNode);
        }
Esempio n. 4
0
        public static void UpdatePlist(string path, string xmlNodeString)
        {
            const string fileName = "Info.plist";
            string       fullPath = Path.Combine(path, fileName);

            PBXPlistDict dict = new PBXPlistDict(fullPath);

            XmlDocument config = new XmlDocument();

            config.LoadXml(xmlNodeString);

            PBXPlistDict dictConfig = new PBXPlistDict(config);

            UpdateDict(dict, dictConfig);

            dict.Save(fullPath);
        }
Esempio n. 5
0
        private object ParseValueForLoad(XElement val)
        {
            switch (val.Name.ToString())
            {
            case TYPE_STRING:
                return(val.Value);

            case TYPE_INTEGER:
                return(int.Parse(val.Value));

            case TYPE_REAL:
                return(float.Parse(val.Value));

            case TYPE_TRUE:
                return(true);

            case TYPE_FALSE:
                return(false);

            case TYPE_DICT:
                PBXPlistDict plist = new PBXPlistDict();
                ParseDictForLoad(plist, val.Elements());
                return(plist);

            case TYPE_ARRAY:
                return(ParseArrayForLoad(val.Elements()));

            case TYPE_NULL:
                return(null);

            case TYPE_DATE:
                return(XmlConvert.ToDateTime(val.Value, XmlDateTimeSerializationMode.Utc));

            case TYPE_DATA:
                return(Convert.FromBase64String(val.Value));

            default:
                CustomDebug.LogWarning("PBXPlistDict: Format unsupported, Parser update needed");
                return(null);
            }
        }