Exemplo n.º 1
0
        public static void Test()
        {
            Assembly a;
            var      bs = BinarySerializerWithString.Create();

            using (var s = Streams.OpenReadable("Assembly.bin"))
            {
                a = bs.Read <Assembly>(s);
            }

            var vc = new VariableContext <int>();

            foreach (var m in a.Modules)
            {
                foreach (var f in m.Functions)
                {
                    vc.Replace(f.Name, f);
                }
            }

            var c = new Calculation(a);

            Trace.Assert(c.Character.GetUpgradeExperience(1, 2) == 2);

            TestBasic(vc);

            TestInteractive(vc);
        }
Exemplo n.º 2
0
        public static void ExpressionSchemaToBinary(List <String> DataDirs, String BinaryPath)
        {
            var ExpressionSchema = GetExpressionSchema();
            var eal = new ExpressionAssemblyLoader(ExpressionSchema);

            foreach (var DataDir in DataDirs)
            {
                foreach (var tf in Directory.EnumerateFiles(DataDir, "*.tree", SearchOption.AllDirectories))
                {
                    eal.LoadAssembly(tf);
                }
            }
            var a  = eal.GetResult();
            var bs = BinarySerializerWithString.Create();

            Byte[] Compiled;
            using (var ms = Streams.CreateMemoryStream())
            {
                bs.Write(a, ms);
                ms.Position = 0;
                Compiled    = ms.Read((int)(ms.Length));
            }
            if (File.Exists(BinaryPath))
            {
                Byte[] Original;
                using (var fs = Streams.OpenReadable(BinaryPath))
                {
                    Original = fs.Read((int)(fs.Length));
                }
                if (Compiled.SequenceEqual(Original))
                {
                    return;
                }
            }
            var BinaryDir = FileNameHandling.GetFileDirectory(BinaryPath);

            if (BinaryDir != "" && !Directory.Exists(BinaryDir))
            {
                Directory.CreateDirectory(BinaryDir);
            }
            using (var fs = Streams.CreateWritable(BinaryPath))
            {
                fs.Write(Compiled);
            }
        }