Exemplo n.º 1
0
        public void DecodeTokenizedBasicToString()
        {
            var basicDecoder = new DragonBasicTokenizer();
            var basicProgram = basicDecoder.Decode(BasicProgramTokens).Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            Assert.Equal(BasicProgramText.Length, basicProgram.Length);
            for (int i = 0; i < BasicProgramText.Length; i++)
            {
                Assert.Equal(BasicProgramText[i], basicProgram[i]);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Write a DragonDos file to a plain data file in the local file system.
 /// </summary>
 /// <param name="file">DragonDos file.</param>
 /// <param name="localFilename">Local filename.</param>
 private void SaveToPlainFile(DragonDosFile file, string localFilename)
 {
     if (file.FileType == DragonDosFileType.Basic && ascii)
     {
         var basicTokenizer = new DragonBasicTokenizer(DragonBasicDialect.DragonDos);
         var basicText      = basicTokenizer.Decode(file.GetData());
         var output         = new StreamWriter(new FileStream(localFilename, FileMode.Create), Encoding.ASCII);
         output.Write(basicText);
         output.Close();
     }
     else
     {
         File.WriteAllBytes(localFilename, file.GetData());
     }
 }