public PBXBuildFile(string guid, PBXDictionary dictionary) : base(guid, dictionary)
        {
            if (!this.data.ContainsKey(SETTINGS_KEY))
            {
                return;
            }
            object settingsObj = this.data[SETTINGS_KEY];

            if (!(settingsObj is PBXDictionary))
            {
                return;
            }
            PBXDictionary settingsDict = (PBXDictionary)settingsObj;

            settingsDict.internalNewlines = false;

            if (!settingsDict.ContainsKey(ATTRIBUTES_KEY))
            {
                return;
            }
            object attributesObj = settingsDict[ATTRIBUTES_KEY];

            if (!(attributesObj is PBXList))
            {
                return;
            }

            PBXList attributesCast = (PBXList)attributesObj;

            attributesCast.internalNewlines = false;
        }
        public PBXObject(string guid, PBXDictionary dictionary) : this( guid )
        {
            if (!dictionary.ContainsKey(ISA_KEY) || ((string)dictionary[ISA_KEY]).CompareTo(this.GetType().Name) != 0)
            {
                Debug.LogError("PBXDictionary is not a valid ISA object");
            }

            foreach (KeyValuePair <string, object> item in dictionary)
            {
                _data[item.Key] = item.Value;
            }
        }
        private PBXDictionary ParseDictionary()
        {
            SkipWhitespaces();
            PBXDictionary dictionary  = new PBXDictionary();
            string        keyString   = string.Empty;
            object        valueObject = null;

            bool complete = false;

            while (!complete)
            {
                switch (NextToken())
                {
                case END_OF_FILE:
                    Debug.Log("Error: reached end of file inside a dictionary: " + index);
                    complete = true;
                    break;

                case DICTIONARY_ITEM_DELIMITER_TOKEN:
                    keyString   = string.Empty;
                    valueObject = null;
                    break;

                case DICTIONARY_END_TOKEN:
                    keyString   = string.Empty;
                    valueObject = null;
                    complete    = true;
                    break;

                case DICTIONARY_ASSIGN_TOKEN:
                    valueObject = ParseValue();
                    if (!dictionary.ContainsKey(keyString))
                    {
                        dictionary.Add(keyString, valueObject);
                    }
                    else
                    {
                        Debug.LogError("ParseDictionary: attempting to add duplicate key: " + keyString);
                        Debug.LogError("ParseDictionary: trying to add value: " + valueObject.ToString());
                        Debug.LogError("ParseDictionary: already added value: " + dictionary[keyString].ToString());
                    }
                    break;

                default:
                    StepBackward();
                    keyString = ParseValue() as string;

                    break;
                }
            }
            return(dictionary);
        }
        public void SetWeakLink(bool weak)
        {
            PBXDictionary settings   = null;
            PBXList       attributes = null;

            if (_data.ContainsKey(SETTINGS_KEY))
            {
                settings = _data[SETTINGS_KEY] as PBXDictionary;
                if (settings.ContainsKey(ATTRIBUTES_KEY))
                {
                    attributes = settings[ATTRIBUTES_KEY] as PBXList;
                }
            }

            if (weak)
            {
                if (settings == null)
                {
                    settings = new PBXDictionary();
                    settings.internalNewlines = false;
                    _data.Add(SETTINGS_KEY, settings);
                }

                if (attributes == null)
                {
                    attributes = new PBXList();
                    attributes.internalNewlines = false;
                    attributes.Add(WEAK_VALUE);
                    settings.Add(ATTRIBUTES_KEY, attributes);
                }
            }
            else
            {
                if (attributes != null && attributes.Contains(WEAK_VALUE))
                {
                    attributes.Remove(WEAK_VALUE);
                }
            }
        }
 public bool ContainsKey(string key)
 {
     return(_data.ContainsKey(key));
 }
Exemple #6
0
        public XCProject(string filePath) : this()
        {
            if (!System.IO.Directory.Exists(filePath))
            {
                Debug.LogWarning("Path does not exists.");
                return;
            }

            if (filePath.EndsWith(".xcodeproj"))
            {
                this.projectRootPath = Path.GetDirectoryName(filePath);
                this.filePath        = filePath;
            }
            else
            {
                string[] projects = System.IO.Directory.GetDirectories(filePath, "*.xcodeproj");
                if (projects.Length == 0)
                {
                    Debug.LogWarning("Error: missing xcodeproj file");
                    return;
                }

                this.projectRootPath = filePath;
                this.filePath        = projects[0];
            }

            projectFileInfo = new FileInfo(Path.Combine(this.filePath, "project.pbxproj"));
            StreamReader sr       = projectFileInfo.OpenText();
            string       contents = sr.ReadToEnd();

            sr.Close();

            PBXParser parser = new PBXParser();

            _datastore = parser.Decode(contents);
            if (_datastore == null)
            {
                throw new System.Exception("Project file not found at file path " + filePath);
            }

            if (!_datastore.ContainsKey("objects"))
            {
                Debug.Log("Errore " + _datastore.Count);
                return;
            }

            _objects = (PBXDictionary)_datastore["objects"];
            modified = false;

            _rootObjectKey = (string)_datastore["rootObject"];
            if (!string.IsNullOrEmpty(_rootObjectKey))
            {
                _project   = new PBXProject(_rootObjectKey, (PBXDictionary)_objects[_rootObjectKey]);
                _rootGroup = new PBXGroup(_rootObjectKey, (PBXDictionary)_objects[_project.mainGroupID]);
            }
            else
            {
                Debug.LogWarning("Error: project has no root object");
                _project   = null;
                _rootGroup = null;
            }
        }