Example #1
0
        public void Build(string path, bool useTry)
        {
            if (builded) return;


            string[] allfile = System.IO.Directory.GetFiles(path, "*.cs", System.IO.SearchOption.AllDirectories);
            int succ = 0;
            Dictionary<string, IList<CSLE.Token>> project = new Dictionary<string, IList<CSLE.Token>>();
            foreach (var file in allfile)
            {
                IList<CSLE.Token> tokens = null;
                if (useTry)
                {

                    try
                    {
                        tokens = env.ParserToken(System.IO.File.ReadAllText(file));

                    }
                    catch (Exception err)
                    {
                        this.Log_Error("ErrInFile:" + file);
                        MessageBox.Show(err.ToString());
                        continue;
                    }
                }
                else
                {
                    tokens = env.ParserToken(System.IO.File.ReadAllText(file));
                }

                project[file] = tokens;
                succ++;
            }
            Log("file parse:" + succ + "/" + allfile.Length);
            if (succ == allfile.Length)
            {
                if (useTry)
                {
                    try
                    {
                        env.Project_Compiler(project, true);
                    }
                    catch (Exception err)
                    {

                        MessageBox.Show(err.ToString());
                    }
                }
                else
                {
                    env.Project_Compiler(project, true);
                }
            }
            builded = true;
            Log("build OK.");
            this.Text = "builded=" + builded;
        }
Example #2
0
        //---------------------------------------------------------------------
        public void create(string dir_script)
        {
            mEnvironment = new CSLE.CLS_Environment((CSLE.ICLS_Logger) this);

            mEnvironment.RegType(new CSLE.RegHelper_Type(typeof(EbLog)));
            mEnvironment.RegType(new CSLE.RegHelper_Type(typeof(EntityMgr)));
            mEnvironment.RegType(new CSLE.RegHelper_Type(typeof(Entity)));
            mEnvironment.RegType(new CSLE.RegHelper_Type(typeof(IComponent)));

            string[] list_script = Directory.GetFiles(dir_script, "*.txt", System.IO.SearchOption.AllDirectories);

            // Build
            Dictionary <string, IList <CSLE.Token> > project = new Dictionary <string, IList <CSLE.Token> >();
            IList <CSLE.Token> tokens;

            foreach (var i in list_script)
            {
                string c = System.IO.File.ReadAllText(i);
                mMapFile[Path.GetFileNameWithoutExtension(i)] = c;
                //EbLog.Note("解析脚本 file_name=" + Path.GetFileNameWithoutExtension(i));
                try
                {
                    tokens = mEnvironment.ParserToken(c);
                    project[Path.GetFileNameWithoutExtension(i)] = tokens;
                }
                catch (Exception ec)
                {
                    EbLog.Error("EbScriptMgr Build Script Error! File=" + i);
                    EbLog.Error(ec.ToString());
                    continue;
                }
            }

            // Compiler
            try
            {
                mEnvironment.Project_Compiler(project, false);
            }
            catch (Exception ec)
            {
                EbLog.Error("EbScriptMgr Compiler Script Error!");
                EbLog.Error(ec.ToString());
            }
        }