Example #1
0
        private void InitPorjectModel(SourceProjectModel projectModel, string srcPath)
        {
            projectModel.AddRefPackage("Z标准包");
            projectModel.AddRefPackage("ZExcel开发包");
            projectModel.ProjectPackageName = "ZLangSingleFile";
            projectModel.BinaryFileKind     = PEFileKinds.ConsoleApplication;
            projectModel.RefDllList         = GetRefDllList(srcPath);

            string          sourceCode = File.ReadAllText(srcPath);
            SourceFileModel fileModel  = new SourceFileModel(srcPath, srcPath, projectModel.EntryClassName,
                                                             projectModel.ProjectPackageName, projectModel.EntryClassName, sourceCode, 1);

            projectModel.AddFile(fileModel);
        }
Example #2
0
        private void InitPorjectModel(SourceProjectModel projectModel, string srcPath)
        {
            //var srcFileInfo =  new FileInfo(srcPath);
            //var projectModel = new SourceProjectModel();
            string srcFileTypeName = Path.GetFileNameWithoutExtension(srcPath);

            //projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory;
            projectModel.BinaryFileKind = PEFileKinds.Dll;
            //projectModel.BinarySaveDirectoryInfo = srcFileInfo.Directory;
            projectModel.ProjectPackageName = "ZLOGOEmit";
            projectModel.EntryClassName     = srcFileTypeName;
            projectModel.BinaryFileNameNoEx = srcFileTypeName;
            //projectModel.ProjectFileInfo = new ZCompileFileInfo( true, srcPath,null,null);
            //projectModel.AddRefPackage("Z语言系统");
            projectModel.AddRefPackage("ZLogoEngine");
            projectModel.AddRefDll(new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZLogoEngine.dll")));
            projectModel.NeedSave = true;
            //ZFileModel classModel = new ZFileModel(new ZCompileFileInfo(false, srcPath, PreCode,null));
            //projectModel.AddClass(classModel);
            //return projectModel;

            string          sourceCode = File.ReadAllText(srcPath);
            SourceFileModel fileModel  = new SourceFileModel(srcPath, srcPath, projectModel.EntryClassName,
                                                             projectModel.ProjectPackageName, projectModel.EntryClassName, sourceCode, 1);

            fileModel.PreSourceCode = PreCode;

            projectModel.AddFile(fileModel);
        }
Example #3
0
        private void InitFile(string srcPath)
        {
            if (File.Exists(srcPath) == false)
            {
                throw new FileNotFoundException("源文件‘" + srcPath + "’不存在");
            }
            srcFileInfo = new FileInfo(srcPath);
            projectModel.ProjectFilePath          = srcPath;
            projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory;
            projectModel.BinarySaveDirectoryInfo  = srcFileInfo.Directory;
            projectModel.EntryClassName           = Path.GetFileNameWithoutExtension(srcFileInfo.FullName);
            projectModel.BinaryFileNameNoEx       = Path.GetFileNameWithoutExtension(srcFileInfo.FullName);
            projectModel.NeedSave = true;

            projectModel.AddRefPackage("Z语言系统");
        }
Example #4
0
        private SourceProjectModel ReadModel()
        {
            FileInfo srcFileInfo = new FileInfo(ProjectFilePath);

            string[]           lines        = File.ReadAllLines(ProjectFilePath);
            SourceProjectModel projectModel = projFileParser.ParseProjectFile(MessageCollection, lines, srcFileInfo.Directory.FullName, ProjectFilePath);

            //projectModel.AddRefPackage("Z语言系统");
            projectModel.AddRefPackage("Z标准包");
            if (projectModel.ProjectRootDirectoryInfo == null)
            {
                projectModel.ProjectRootDirectoryInfo = srcFileInfo.Directory;
            }
            if (projectModel.BinarySaveDirectoryInfo == null)
            {
                projectModel.BinarySaveDirectoryInfo = srcFileInfo.Directory;
            }

            return(projectModel);
        }
Example #5
0
        public SourceProjectModel ParseProjectFile(CompileMessageCollection messageCollection, string[] lines,
                                                   string folderPath, string projectFilePath)//, ZCompileFileInfo zfileInfo)
        {
            SourceProjectModel projectModel = new SourceProjectModel();

            projectModel.NeedSave = true;
            projectModel.AddRefPackage("Z语言系统");

            for (int i = 0; i < lines.Length; i++)
            {
                string code = lines[i];
                if (string.IsNullOrEmpty(code))
                {
                    continue;
                }
                else if (code.StartsWith("//"))
                {
                    continue;
                }
                else if (code.StartsWith("包名称:"))
                {
                    string name = code.Substring(4);
                    projectModel.ProjectPackageName = name;
                    projectModel.BinaryFileNameNoEx = name;
                }
                else if (code.StartsWith("生成类型:"))
                {
                    string      lx       = code.Substring(5);
                    PEFileKinds fileKind = PEFileKinds.ConsoleApplication;
                    if (lx == "开发包")
                    {
                        fileKind = PEFileKinds.Dll;
                    }
                    else if (lx == "控制台程序")
                    {
                        fileKind = PEFileKinds.ConsoleApplication;
                    }
                    else if (lx == "桌面程序")
                    {
                        fileKind = PEFileKinds.WindowApplication;
                    }
                    projectModel.BinaryFileKind = fileKind;
                }
                else if (code.StartsWith("编译:"))
                {
                    string src = code.Substring(3);
                    //string srcPath = Path.Combine(folderPath, src);

                    SourceFileModel classModel = readFileModel(folderPath, src, projectModel.ProjectPackageName);// new SourceFileModel(new ZCompileFileInfo(false, srcPath, null, null));
                    projectModel.AddFile(classModel);
                }
                else if (code.StartsWith("设置启动:"))
                {
                    string name = code.Substring(5);
                    projectModel.EntryClassName = name;
                }
                else if (code.StartsWith("保存:"))
                {
                    string name = code.Substring(3);
                    projectModel.BinaryFileNameNoEx = name;
                }
                else
                {
                    messageCollection.AddError(
                        new CompileMessage(new CompileMessageSrcKey(projectFilePath), i + 1, 0, "项目指令'" + code + "'无效"));
                }
            }
            return(projectModel);
        }