CreateDict() public method

public CreateDict ( string key ) : PlistElementDict
key string
return PlistElementDict
コード例 #1
0
    private static void AddElementInfoPlist(string pathToBuiltProject)
    {
#if UNITY_IOS
        // Get plist
        string plistPath = pathToBuiltProject + "/Info.plist";
        var    plist     = new UnityEditor.iOS.Xcode.PlistDocument();
        plist.ReadFromString(File.ReadAllText(plistPath));
        bool changed = false;

        // Get root
        UnityEditor.iOS.Xcode.PlistElementDict rootDict = plist.root;

        foreach (var p in InfoPlist)
        {
            if (!rootDict.values.ContainsKey(p.Key))
            {
                rootDict.CreateDict(p.Key);
            }
            rootDict.SetString(p.Key, p.Value);
            changed = true;
        }

        if (changed)
        {
            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());
        }
#endif
    }
コード例 #2
0
ファイル: XcodeSetting.cs プロジェクト: li5414/Usdk
 //设置plist
 private static void SetPlist(PBXProject proj, PlistElementDict node, Hashtable arg)
 {
     if (arg != null)
     {
         foreach (DictionaryEntry i in arg)
         {
             string key   = i.Key.ToString();
             object val   = i.Value;
             var    vType = i.Value.GetType();
             if (vType == typeof(string))
             {
                 node.SetString(key, (string)val);
             }
             else if (vType == typeof(bool))
             {
                 node.SetBoolean(key, (bool)val);
             }
             else if (vType == typeof(double))
             {
                 int v = int.Parse(val.ToString());
                 node.SetInteger(key, v);
             }
             else if (vType == typeof(ArrayList))
             {
                 var t     = node.CreateArray(key);
                 var array = val as ArrayList;
                 SetPlist(proj, t, array);
             }
             else if (vType == typeof(Hashtable))
             {
                 var t     = node.CreateDict(key);
                 var table = val as Hashtable;
                 SetPlist(proj, t, table);
             }
         }
     }
 }