Example #1
0
 static void Unpack(string source, string output)
 {
     source = Path.Combine(CurrentDirectory, source);
     output = Path.Combine(CurrentDirectory, output);
     try {
         byte[] buffer = GetFileBuffer(source);
         File.WriteAllBytes(output, Encoding.UTF8.GetBytes(ScorpioMaker.DeserializeToString(buffer)));
     } catch (System.Exception ex) {
         Console.WriteLine("转换出错 error : " + ex.ToString());
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            string type   = "";     //类型 1解析 0转换
            string source = "";     //源文件
            string target = "";     //目标文件

            try {
                for (int i = 0; i < args.Length; ++i)
                {
                    if (args[i] == "-t")
                    {
                        type = args[i + 1];
                    }
                    else if (args[i] == "-s")
                    {
                        source = args[i + 1];
                    }
                    else if (args[i] == "-o")
                    {
                        target = args[i + 1];
                    }
                }
            } catch (System.Exception ex) {
                Console.WriteLine("参数出错 -t [类型 1解析 0转换] -s [源文件] -o [输出文件] error : " + ex.ToString());
                goto exit;
            }
            if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(target))
            {
                Console.WriteLine("参数出错 -t [类型 1解析 0转换] -s [源文件] -o [输出文件] ");
                goto exit;
            }
            source = Path.Combine(Environment.CurrentDirectory, source);
            if (string.IsNullOrEmpty(source))
            {
                target = source + ".sco";
            }
            target = Path.Combine(Environment.CurrentDirectory, target);
            try {
                byte[] buffer = GetFileBuffer(source);
                if (type.Equals("1"))
                {
                    File.WriteAllBytes(target, Encoding.UTF8.GetBytes(ScorpioMaker.DeserializeToString(buffer)));
                }
                else
                {
                    File.WriteAllBytes(target, ScorpioMaker.Serialize(source, Encoding.UTF8.GetString(buffer, 0, buffer.Length)));
                }
            } catch (System.Exception ex) {
                Console.WriteLine("转换出错 error : " + ex.ToString());
            }
exit:
            Console.WriteLine("转换结束");
        }
Example #3
0
 public ScriptObject LoadFile(String fileName, Encoding encoding)
 {
     try {
         byte[] buffer = ScriptExtensions.GetFileBuffer(fileName);
         if (buffer.Length > 0 && buffer[0] == 0)
         {
             return(LoadTokens(fileName, ScorpioMaker.Deserialize(buffer)));
         }
         else
         {
             return(LoadString(fileName, encoding.GetString(buffer, 0, buffer.Length)));
         }
     } catch (System.Exception e) {
         throw new ScriptException("load file [" + fileName + "] is error : " + e.ToString());
     }
 }
Example #4
0
 public ScriptObject LoadBuffer(String strBreviary, byte[] buffer, Encoding encoding)
 {
     if (buffer == null || buffer.Length == 0)
     {
         return(null);
     }
     try {
         if (buffer[0] == 0)
         {
             return(LoadTokens(strBreviary, ScorpioMaker.Deserialize(buffer)));
         }
         else
         {
             return(LoadString(strBreviary, encoding.GetString(buffer, 0, buffer.Length)));
         }
     } catch (System.Exception e) {
         throw new ScriptException("load buffer [" + strBreviary + "] is error : " + e.ToString());
     }
 }
Example #5
0
        public ScriptObject LoadBuffer(string strBreviary, byte[] buffer, Encoding encoding)
        {
            ScriptObject obj2;

            if ((buffer == null) || (buffer.Length == 0))
            {
                return(null);
            }
            try
            {
                if (buffer[0] == 0)
                {
                    return(this.LoadTokens(strBreviary, ScorpioMaker.Deserialize(buffer)));
                }
                obj2 = this.LoadString(strBreviary, encoding.GetString(buffer, 0, buffer.Length));
            }
            catch (System.Exception exception)
            {
                throw new ScriptException("load buffer [" + strBreviary + "] is error : " + exception.ToString());
            }
            return(obj2);
        }