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); } break; default: StepBackward(); keyString = ParseValue() as string; break; } } return(dictionary); }
public bool ContainsKey(string key) { return(_data.ContainsKey(key)); }
public XCProject(string filePath) : this() { if (!System.IO.Directory.Exists(filePath)) { Debug.LogWarning("XCode project path does not exist: " + filePath); return; } if (filePath.EndsWith(".xcodeproj")) { Debug.Log("Opening project " + filePath); this.projectRootPath = Path.GetDirectoryName(filePath); this.filePath = filePath; } else { Debug.Log("Looking for xcodeproj files in " + filePath); string[] projects = System.IO.Directory.GetDirectories(filePath, "*.xcodeproj"); if (projects.Length == 0) { Debug.LogWarning("Error: missing xcodeproj file"); return; } this.projectRootPath = filePath; //if the path is relative to the project, we need to make it absolute if (!System.IO.Path.IsPathRooted(projectRootPath)) { projectRootPath = Application.dataPath.Replace("Assets", "") + projectRootPath; Debug.Log("projectRootPath adjusted to " + projectRootPath); } this.filePath = projects [0]; } projectFileInfo = new FileInfo(Path.Combine(this.filePath, "project.pbxproj")); string contents = projectFileInfo.OpenText().ReadToEnd(); 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; } }
public void AddSystemCapabilities(string capabilities, bool isEnabled) { string enabled; if (isEnabled) { enabled = "1"; } else { enabled = "0"; } Debug.Log("in AddSystemCapabilities"); PBXDictionary _Attributes = (PBXDictionary)_project.data ["attributes"]; PBXDictionary _TargetAttributes = (PBXDictionary)_Attributes ["TargetAttributes"]; PBXList _targets = (PBXList)_project.data ["targets"]; PBXDictionary targetDict = null; Debug.Log("_TargetAttributes:" + _TargetAttributes); if (_TargetAttributes.ContainsKey((string)_targets [0])) { targetDict = (PBXDictionary)_TargetAttributes [(string)_targets [0]]; } else //不会发生 // Debug.Log ("AddSystemCapabilities error"); // return; { targetDict = new PBXDictionary(); } Debug.Log("targetDict:" + targetDict); PBXDictionary SystemCapabilities = null; if (targetDict != null && targetDict.ContainsKey("SystemCapabilities")) { Debug.Log("xxxxxxxxxxxxxxxxxxx"); SystemCapabilities = (PBXDictionary)targetDict ["SystemCapabilities"]; } else { SystemCapabilities = new PBXDictionary(); } Debug.Log("before SystemCapabilities:" + SystemCapabilities); if (SystemCapabilities != null && SystemCapabilities.ContainsKey(capabilities)) { SystemCapabilities.Remove(capabilities); } Debug.Log("after SystemCapabilities:" + SystemCapabilities); PBXDictionary enable = new PBXDictionary(); enable.Add("enabled", enabled); SystemCapabilities.Add(capabilities, enable); Debug.Log("after SystemCapabilities:" + SystemCapabilities); if (!targetDict.ContainsKey("SystemCapabilities")) { // Debug.Log ("rrrrrrrrrrrrrrrrrrrrrr"); targetDict.Add("SystemCapabilities", SystemCapabilities); } if (!_TargetAttributes.ContainsKey((string)_targets [0])) { // Debug.Log ("hhhhhhhhhhhhhhhhhhhhh"); _TargetAttributes.Add((string)_targets [0], targetDict); } Debug.Log("after attributes:" + _TargetAttributes); Debug.Log("AddSystemCapabilities done"); }