LynnaLab.FileParser.InsertParseableTextAfter C# (CSharp) Method

InsertParseableTextAfter() public method

public InsertParseableTextAfter ( FileComponent refComponent, string text ) : bool
refComponent FileComponent
text string
return bool
        public bool InsertParseableTextAfter(FileComponent refComponent, string[] text)
        {
            int index;
            if (refComponent == null)
                index = fileStructure.Count-1;
            else {
                index = fileStructure.IndexOf(refComponent);
                if (index == -1)
                    return false;
            }

            context = "";
            List<FileComponent> structure = new List<FileComponent>();
            List<string> structureComments = new List<string>();

            for (int i=0;i<text.Length;i++) {
                ParseLine(text[i], i, structure, structureComments);
            }

            fileStructure.InsertRange(index+1, structure);
            fileStructureComments.InsertRange(index+1, structureComments);

            return true;
        }

Usage Example

コード例 #1
0
ファイル: ObjectGroup.cs プロジェクト: turbo3001/LynnaLab
        public void InsertObject(int index, ObjectType type)
        {
            if (GetNumObjects() == 0 && !IsIsolated())
            {
                // If this map is sharing data with other maps (as when "blank"), need to make
                // a unique section for this map.

                parser.RemoveLabel(Identifier);

                parser.InsertParseableTextAfter(null, new String[] { "" }); // Newline
                parser.InsertComponentAfter(null, new Label(parser, Identifier));

                ObjectData endData = new ObjectData(Project,
                                                    ObjectCommands[(int)ObjectType.End],
                                                    null,
                                                    parser,
                                                    new string[] { "\t" }, // Tab at start of line
                                                    ObjectType.End);
                parser.InsertComponentAfter(null, endData);
                objectDataList[0] = endData;
            }

            ObjectData data = new ObjectData(Project,
                                             ObjectCommands[(int)type],
                                             null,
                                             parser,
                                             new string[] { "\t" }, // Tab at start of line
                                             type);

            ValueReference.InitializeDataValues(data, data.GetValueReferences());

            if (type >= ObjectType.Pointer && type <= ObjectType.AntiBossPointer)
            {
                data.SetValue(0, "objectData4000"); // Compileable default pointer
            }
            data.InsertIntoParserBefore(objectDataList[index]);
            objectDataList.Insert(index, data);
        }