コード例 #1
0
ファイル: fileparser.cs プロジェクト: KillerGoldFisch/GCharp
        public ScriptParser(string fileName)
        {
            referencedNamespaces = new ArrayList();
            referencedAssemblies = new ArrayList();

            //process main file
            FileParser mainFile = new FileParser(fileName, null, true, false, null);
            this.apartmentState = mainFile.apartmentState;

            foreach (string namespaceName in mainFile.ReferencedNamespaces)
                PushNamespace(namespaceName);

            foreach (string asmName in mainFile.ReferencedAssemblies)
                PushAssembly(asmName);

            this.searchDirs = new string[] {Path.GetDirectoryName(mainFile.fileName)}; //note: mainFile.fileName is warrantied to be a full name but fileName is not

            //process impported files if any
            foreach (ScriptInfo fileInfo in mainFile.ReferencedScripts)
                ProcessFile(fileInfo);

            //Main script file shall always be the first. Add it now as previously array was sorted a few times
            this.fileParsers.Insert(0, mainFile);
        }
コード例 #2
0
ファイル: fileparser.cs プロジェクト: KillerGoldFisch/GCharp
        private void ProcessFile(ScriptInfo fileInfo)
        {
            FileParserComparer fileComparer = new FileParserComparer();

            FileParser importedFile = new FileParser(fileInfo.fileName, fileInfo.parseParams, false, true, this.searchDirs); //do not parse it yet (the third param is false)
            if (fileParsers.BinarySearch(importedFile, fileComparer) < 0)
            {
                importedFile.ProcessFile(); //parse now namespaces, ref. assemblies and scripts; also it will do namespace renaming

                this.fileParsers.Add(importedFile);
                this.fileParsers.Sort(fileComparer);

                foreach (string namespaceName in importedFile.ReferencedNamespaces)
                    PushNamespace(namespaceName);

                foreach (string asmName in importedFile.ReferencedAssemblies)
                    PushAssembly(asmName);

                foreach(ScriptInfo scriptFile in importedFile.ReferencedScripts)
                    ProcessFile(scriptFile);
            }
        }