Exemplo n.º 1
0
        public string GlobalCompile()
        {
            string[] FileText     = System.IO.File.ReadAllLines(FileName);
            string   FileNamePath = "";

            if (FileName.Split('/').Length > 1)
            {
                FileNamePath = FileName.Remove(FileName.Length - FileName.Split('/')[FileName.Split('/').Length - 1].Length - 1);
            }
            else
            {
                FileNamePath = FileName.Remove(FileName.Length - FileName.Split('\\')[FileName.Split('\\').Length - 1].Length - 1);
            }
            string[]   ConfigLines   = System.IO.File.ReadAllLines(FileNamePath + "/config.bk");
            string[]   DataLines     = {};
            WebProject CurrenProject = new WebProject();

            CurrenProject.ProjectStopWatch.Start();
            if (System.IO.File.Exists(FileNamePath + "/data.bk"))
            {
                DataLines = System.IO.File.ReadAllLines(FileNamePath + "/data.bk");
                for (int i = 0; i < DataLines.Length; i++)
                {
                    string[] LocalLine = SyntaxTools.GetNewLine(DataLines[i]).Split('=');
                    CurrenProject.AddData(LocalLine[0], LocalLine[1]);
                }
            }
            this.HTML_Path = FileNamePath + ConfigLines[0].Split('=')[1];
            VerifyFolder(this.HTML_Path);
            this.CSS_Path = FileNamePath + ConfigLines[1].Split('=')[1];
            VerifyFolder(this.CSS_Path);
            bool Started = false;

            WebObject.Base CurrentObject = new WebObject.Base("default", CurrenProject, "", "");
            FileLines = new List <string>();
            AddFileLines(FileText, FileNamePath);
            for (int i = 0; i < FileLines.Count; i++)
            {
                string[] LinesWords = FileLines[i].Split(' ');

                if (LinesWords[0] == "page")
                {
                    CurrentObject = new WebObject.Page(LinesWords[1], CurrenProject, HTML_Path, CSS_Path);
                    Started       = true;
                }
                else if (LinesWords[0] == "object")
                {
                    if (LinesWords[1].Split(':').Length > 1)
                    {
                        string[] LocalWords = LinesWords[1].Split(':');
                        CurrentObject = new WebObject.Base(LocalWords[0], CurrenProject, HTML_Path, CSS_Path);
                        foreach (WebObject.Base LocalObject in CurrenProject.ObjectList)
                        {
                            if (LocalObject.GetName() == LocalWords[1])
                            {
                                CurrentObject.CSS.SetAllProp(LocalObject, LocalObject.CSS.GetAllProp());
                            }
                        }
                    }
                    else
                    {
                        CurrentObject = new WebObject.Base(LinesWords[1], CurrenProject, HTML_Path, CSS_Path);
                    }
                    Started = true;
                }
                else if (Started && LinesWords[0] == "end")
                {
                    CurrentObject.CompileObject();
                    CurrenProject.ObjectList.Add(CurrentObject);
                    Started = false;
                }
                else if (Started)
                {
                    CurrentObject.AddLine(FileLines[i]);
                }
            }
            CurrenProject.DisplayCompileTime();
            return("ExitCode = 0");
        }