예제 #1
0
        public bool AddPushSystemCapabilities(bool value)
        {
            bool modified = false;

            PBXList targets = ((PBXList)_data [TARGET_KEY]);

            if (!ContainsKey(ATTRIBUTES_KEY))
            {
                this.Add(ATTRIBUTES_KEY, new PBXDictionary());
                modified = true;
            }

            PBXDictionary attributes = ((PBXDictionary)_data [ATTRIBUTES_KEY]);

            if (!attributes.ContainsKey(TARGET_ATTRIBUTES_KEY))
            {
                attributes.Add(TARGET_ATTRIBUTES_KEY, new PBXDictionary());
                modified = true;
            }

            PBXDictionary targetAttributes = ((PBXDictionary)attributes [TARGET_ATTRIBUTES_KEY]);

            foreach (object target in targets)
            {
                string targetKey = (string)target;

                if (!targetAttributes.ContainsKey(targetKey))
                {
                    targetAttributes.Add(targetKey, new PBXDictionary());
                    PBXDictionary targetAttribute = (PBXDictionary)targetAttributes [targetKey];

                    targetAttribute.Add("SystemCapabilities", new PBXDictionary());
                    PBXDictionary systemCapabilities = (PBXDictionary)targetAttribute ["SystemCapabilities"];

                    systemCapabilities.Add("com.apple.Push", new PBXDictionary());
                    PBXDictionary applePush = (PBXDictionary)systemCapabilities ["com.apple.Push"];

                    if (value)
                    {
                        applePush.Add("enabled", 1);
                    }
                    else
                    {
                        applePush.Add("enabled", 0);
                    }

                    modified = true;
                }
                else
                {
                    PBXDictionary targetAttribute = (PBXDictionary)targetAttributes [targetKey];
                    if (!targetAttribute.ContainsKey(TEST_TARGET_ID_KEY))
                    {
                        if (!targetAttribute.ContainsKey("SystemCapabilities"))
                        {
                            targetAttribute.Add("SystemCapabilities", new PBXDictionary());
                        }
                        PBXDictionary systemCapabilities = (PBXDictionary)targetAttribute ["SystemCapabilities"];

                        if (!systemCapabilities.ContainsKey("com.apple.Push"))
                        {
                            systemCapabilities.Add("com.apple.Push", new PBXDictionary());
                        }
                        PBXDictionary applePush = (PBXDictionary)systemCapabilities ["com.apple.Push"];

                        if (applePush.ContainsKey("enabled"))
                        {
                            applePush.Remove("enabled");
                        }

                        if (value)
                        {
                            applePush.Add("enabled", 1);
                        }
                        else
                        {
                            applePush.Add("enabled", 0);
                        }

                        modified = true;
                    }
                }
            }
            return(modified);
        }
예제 #2
0
 public bool Remove(string key)
 {
     return(_data.Remove(key));
 }