Ejemplo n.º 1
0
        public void LoadProjectFromPacket(string _PathFile)
        {
            try
            {
                using (AESReader treader = new AESReader(_PathFile))
                {
                    int    len      = treader.ReadInt32();
                    byte[] tbuffer  = treader.ReadBytes(len);
                    byte[] tdllbyts = null;
                    byte[] tpdbbyts = null;
                    Stream tstream  = new MemoryStream(tbuffer);
                    #region build ProjectList

                    using (ZipInputStream f = new ZipInputStream(tstream))
                    {
                        while (true)
                        {
                            ZipEntry zp = f.GetNextEntry();
                            if (zp == null)
                            {
                                break;
                            }
                            if (!zp.IsDirectory && zp.Crc != 00000000L)
                            {
                                byte[] b        = new byte[f.Length];
                                int    treadlen = f.Read(b, 0, b.Length);

                                //取得文件所有数据
                                if (zp.Name.Contains(".dll"))
                                {
                                    tdllbyts = b;
                                }
                                else if (zp.Name.Contains(".pdb"))
                                {
                                    tpdbbyts = b;
                                }
                            }
                        }
                        f.Close();
                    }
                    #endregion
                    tstream.Close();
                    LoadProjectByBytes(tdllbyts, tpdbbyts);
                }
            }
            catch (Exception err)
            {
                DLog.LogError("loadpacket" + err);
            }
        }
Ejemplo n.º 2
0
        public void LoadScriptFormFile(string _filename)
        {
            if (mCore.SManager.ProjectLoaded)
            {
                DLog.LogError("脚本不可重复加载.");
                return;
            }

            byte[] dllbytes = null;
            byte[] pdbbytes = null;

            string tdllPath = mCore.AppPersistentScriptDataPath + _filename;

            if (System.IO.File.Exists(tdllPath + ".dll"))
            {
                dllbytes = System.IO.File.ReadAllBytes(tdllPath + ".dll");
                pdbbytes = System.IO.File.ReadAllBytes(tdllPath + ".pdb");
            }

            if (dllbytes == null || pdbbytes == null)
            {
                DLog.LogErrorFormat("LoadScriptFormFile{dllbytes = {0},pdbbytes = {1}}", dllbytes, pdbbytes);
                return;
            }

            AESReader tdllreader = new AESReader(dllbytes);
            AESReader tpdbreader = new AESReader(pdbbytes);

            dllbytes = tdllreader.ReadAllBytes();
            pdbbytes = tpdbreader.ReadAllBytes();

            tdllreader.Dispose();
            tpdbreader.Dispose();

            LoadScriptFormMemory(dllbytes, pdbbytes);
        }