public void FromStream_ShouldNotBeNullAndIsSameVersion_Version3BigEndian()
        {
            using (var fileStream = File.OpenRead("TestResources\\Version3BigEndian.bf"))
            {
                var script = FlowScript.FromStream(fileStream, null, FormatVersion.Version3BigEndian, false);

                Assert.IsNotNull(script);
                Assert.AreEqual(FormatVersion.Version3BigEndian, script.FormatVersion);
            }
        }
예제 #2
0
        public static Stream RandomizeFlowScript(Stream stream)
        {
            var flowScript = FlowScript.FromStream(stream, true);

            if (flowScript.MessageScript == null)
            {
                return(stream);
            }

            RandomizeMessageScript(flowScript.MessageScript);

            return(flowScript.ToStream());
        }
예제 #3
0
        public static Stream FixFlowScript(Stream stream, Stream originalStream)
        {
            var flowScript         = FlowScript.FromStream(stream, true);
            var originalFlowScript = FlowScript.FromStream(originalStream, true);

            if (flowScript.MessageScript == null)
            {
                return(stream);
            }

            FixMessageScript(flowScript.MessageScript, originalFlowScript.MessageScript);

            return(flowScript.ToStream());
        }
예제 #4
0
 private static IEnumerable <(FlowScript, string)> FindFlowScripts(string file, Archive archive = null, string archiveFilePath = null)
 {
     if (file.EndsWith("bf", StringComparison.InvariantCultureIgnoreCase))
     {
         if (archive == null)
         {
             yield return(FlowScript.FromFile(file, sEncoding), file);
         }
         else
         {
             yield return(FlowScript.FromStream(archive.OpenFile(file), sEncoding), Path.Combine(archiveFilePath, file));
         }
     }
     else if (archive == null ? Archive.TryOpenArchive(File.OpenRead(file), out var subArchive) : Archive.TryOpenArchive(archive.OpenFile(file), out subArchive))
     {
         foreach (string entry in subArchive)
         {
             foreach (var script in FindFlowScripts(entry, subArchive, archive == null ? file : Path.Combine(archiveFilePath, file)))
             {
                 yield return(script);
             }
         }
     }
 }