Ejemplo n.º 1
0
        public void ReadFromStream(TextReader sr)
        {
            this.Clear();
            this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd());
            if (!this.m_RootElements.Contains("objects"))
            {
                throw new Exception("Invalid PBX project file: no objects element");
            }
            PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict();

            this.m_RootElements.Remove("objects");
            this.m_RootElements.SetString("objects", "OBJMARKER");
            if (this.m_RootElements.Contains("objectVersion"))
            {
                this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString();
                this.m_RootElements.Remove("objectVersion");
            }
            List <string> allGuids        = new List <string>();
            string        prevSectionName = (string)null;

            foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values)
            {
                allGuids.Add(keyValuePair.Key);
                PBXElement pbxElement = keyValuePair.Value;
                if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa"))
                {
                    this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement);
                }
                else
                {
                    PBXElementDict pbxElementDict2 = pbxElement.AsDict();
                    string         index1          = pbxElementDict2["isa"].AsString();
                    if (this.m_Section.ContainsKey(index1))
                    {
                        this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2);
                    }
                    else
                    {
                        KnownSectionBase <PBXObjectData> knownSectionBase;
                        if (this.m_UnknownSections.ContainsKey(index1))
                        {
                            knownSectionBase = this.m_UnknownSections[index1];
                        }
                        else
                        {
                            knownSectionBase = new KnownSectionBase <PBXObjectData>(index1);
                            this.m_UnknownSections.Add(index1, knownSectionBase);
                        }
                        knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2);
                        if (!this.m_SectionOrder.Contains(index1))
                        {
                            int index2 = 0;
                            if (prevSectionName != null)
                            {
                                index2 = this.m_SectionOrder.FindIndex((Predicate <string>)(x => x == prevSectionName)) + 1;
                            }
                            this.m_SectionOrder.Insert(index2, index1);
                        }
                    }
                    prevSectionName = index1;
                }
            }
            this.RepairStructure(allGuids);
            this.RefreshAuxMaps();
        }
Ejemplo n.º 2
0
        public void ReadFromStream(TextReader sr)
        {
            this.Clear();
            this.m_RootElements = PBXProjectData.ParseContent(sr.ReadToEnd());
            if (!this.m_RootElements.Contains("objects"))
            {
                throw new Exception("Invalid PBX project file: no objects element");
            }
            PBXElementDict pbxElementDict1 = this.m_RootElements["objects"].AsDict();

            this.m_RootElements.Remove("objects");
            this.m_RootElements.SetString("objects", "OBJMARKER");
            if (this.m_RootElements.Contains("objectVersion"))
            {
                this.m_ObjectVersion = this.m_RootElements["objectVersion"].AsString();
                this.m_RootElements.Remove("objectVersion");
            }
            List <string> allGuids = new List <string>();
            // ISSUE: reference to a compiler-generated field
            string prevSectionName = null;

            foreach (KeyValuePair <string, PBXElement> keyValuePair in (IEnumerable <KeyValuePair <string, PBXElement> >)pbxElementDict1.values)
            {
                allGuids.Add(keyValuePair.Key);
                PBXElement pbxElement = keyValuePair.Value;
                if (!(pbxElement is PBXElementDict) || !pbxElement.AsDict().Contains("isa"))
                {
                    this.m_UnknownObjects.values.Add(keyValuePair.Key, pbxElement);
                }
                else
                {
                    PBXElementDict pbxElementDict2 = pbxElement.AsDict();
                    string         index1          = pbxElementDict2["isa"].AsString();
                    if (this.m_Section.ContainsKey(index1))
                    {
                        this.m_Section[index1].AddObject(keyValuePair.Key, pbxElementDict2);
                    }
                    else
                    {
                        KnownSectionBase <PBXObjectData> knownSectionBase;
                        if (this.m_UnknownSections.ContainsKey(index1))
                        {
                            knownSectionBase = this.m_UnknownSections[index1];
                        }
                        else
                        {
                            knownSectionBase = new KnownSectionBase <PBXObjectData>(index1);
                            this.m_UnknownSections.Add(index1, knownSectionBase);
                        }
                        knownSectionBase.AddObject(keyValuePair.Key, pbxElementDict2);
                        if (!this.m_SectionOrder.Contains(index1))
                        {
                            int pos = 0;
                            if (prevSectionName != null)
                            {
                                // this never fails, because we already added any previous unknown sections
                                // to m_SectionOrder
                                pos  = m_SectionOrder.FindIndex(x => x == prevSectionName);
                                pos += 1;
                            }
                            m_SectionOrder.Insert(pos, index1);
                        }
                    }
                    // ISSUE: reference to a compiler-generated field
                    prevSectionName = index1;
                }
            }
            this.RepairStructure(allGuids);
            this.RefreshAuxMaps();
        }