Beispiel #1
0
        public TKTXMFileModel Parse(FileInfo projectFileInfo)
        {
            //ProjectCompileResult result = new ProjectCompileResult();
            string[] lines = File.ReadAllLines(projectFileInfo.FullName);
            //FileInfo projectFileInfo = new FileInfo(projfile);
            string         folder = projectFileInfo.Directory.FullName;
            TKTXMFileModel model  = CompileLines(lines);

            return(model);
        }
Beispiel #2
0
        public TKTXMFileModel CompileLines(string[] lines)
        {
            TKTXMFileModel model = new TKTXMFileModel();

            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);
                    //context.RootNameSpace = name;
                    model.PackageName = name;
                }
                else if (code.StartsWith("生成类型:"))
                {
                    string lx = code.Substring(5);
                    model.GenerateType = lx;
                }
                else if (code.StartsWith("编译:"))
                {
                    string src = code.Substring(3);
                    model.SrcFiles.Add(src);
                }
                else if (code.StartsWith("设置启动:"))
                {
                    string name = code.Substring(5);
                    model.Entry = name;
                }
                else
                {
                    //throw new CompileException("无法识别项目编译指令:" + code);
                    //errorf(result, file, i + 1, 1, "无法识别项目编译指令:'{0}'", code);
                    //continue;
                }
            }
            return(model);
        }
Beispiel #3
0
        public TKTXMFileModel ShowClass(FileInfo fi)
        {
            TKTXMFileModel model = parser.Parse(fi);

            if (model != null)
            {
                ShowClass(model, fi);
                return(model);
            }
            //string code = File.ReadAllText(fi.FullName);
            //var tokens = scanner.Scan(code);
            //TKTXMFileModel tktclass = parser.Parse(tokens);
            //if (tktclass.NameModel == null)
            //{
            //    tktclass.NameModel = new TKTContentModel() { Content = Path.GetFileName(fi.FullName) };
            //}
            //ShowClass(model, fi);
            return(null);
        }
Beispiel #4
0
        public void ShowClass(TKTXMFileModel tktclass, FileInfo fi)
        {
            ClearTree();
            if (tktclass == null)
            {
                return;
            }

            TreeNode xmNode = new TreeNode();

            xmNode.Text = fi.Name;
            xmNode.Tag  = fi.FullName;
            projTreeView.Nodes.Add(xmNode);

            foreach (var pp in tktclass.SrcFiles)
            {
                TreeNode pnode = new TreeNode();
                pnode.Text = pp;
                pnode.Tag  = Path.Combine(fi.Directory.FullName, pp);
                projTreeView.Nodes.Add(pnode);
            }
            projTreeView.ExpandAll();
        }