コード例 #1
0
        public void TestConstructBytes()
        {
            foreach (var testData in Tests)
            {
                var filebytes = File.ReadAllBytes(testData.CompressedFilePath);

                var resource = LuaScriptResource.Create(testData.RecordInfo.VersionHash);
                resource.InitFromRawCompressed(filebytes);
                Assert.AreEqual(resource.Resource.Filename, testData.ExpectedFileName);
                Assert.AreEqual(resource.Resource.Source, ExpectedSource);
            }
        }
コード例 #2
0
        protected override void CustomFileExport(ExportParameters exportParameters)
        {
            var scriptCompiledBytecode = LuaScriptResource.Create(exportParameters.FileRecord.Info?.VersionHash ?? string.Empty);

            scriptCompiledBytecode.InitFromRecord(exportParameters.BagStream, exportParameters.FileRecord);

            var outputPath = Path.GetFullPath(Path.Combine(exportParameters.OutputDirectory, exportParameters.FileRecord.Name + exportParameters.FileExtension));

            File.WriteAllText(outputPath, scriptCompiledBytecode.Resource.Source);

            exportParameters.OnProgressReport?.Invoke(exportParameters.FileRecord, 0);
        }
コード例 #3
0
        public void TestConstructCompressedStream()
        {
            foreach (var testData in Tests)
            {
                var compressedFileBytes = File.ReadAllBytes(testData.CompressedFilePath);

                using (var ms = new MemoryStream(compressedFileBytes))
                {
                    var resource = LuaScriptResource.Create(testData.RecordInfo.VersionHash);
                    resource.InitFromStream(ms);
                    Assert.AreEqual(resource.Resource.Filename, testData.ExpectedFileName);
                    Assert.AreEqual(resource.Resource.Source, ExpectedSource);
                }
            }
        }
コード例 #4
0
        public void TestConstructFileInfo()
        {
            foreach (var testData in Tests)
            {
                var fileStream = File.OpenRead(testData.CompressedFilePath);
                var fileRecord = new FileRecord
                {
                    Length      = (uint)fileStream.Length,
                    Info        = null,
                    Offset      = 0,
                    TimestampNs = 0,
                    Name        = "File Record"
                };

                var resource = LuaScriptResource.Create(testData.RecordInfo.VersionHash);
                resource.InitFromRecord(fileStream, fileRecord);
                Assert.AreEqual(resource.Resource.Filename, testData.ExpectedFileName);
                Assert.AreEqual(resource.Resource.Source, ExpectedSource);
            }
        }