Пример #1
0
 public override void Save(IModFileSaver saver)
 {
     using (var stream = _loader.OpenStream())
     {
         saver.Save(Path, stream);
     }
 }
Пример #2
0
        private string LoadSCFileContents(IModFileLoader loader)
        {
            using (var stream = loader.OpenStream())
            {
                using (var mr = new MemoryStream())
                {
                    byte[] buffer = new byte[1024];
                    int    size   = 0;
                    while (stream.CanRead && ((size = stream.Read(buffer, 0, 1024)) > 0))
                    {
                        mr.Write(buffer, 0, size);
                    }

                    mr.Seek(0, SeekOrigin.Begin);

                    var parser = new Parser(new Scanner(mr));

                    parser.Parse();

                    mr.Seek(0, SeekOrigin.Begin);

                    using (var sr = new StreamReader(mr))
                    {
                        ParseError = parser.ParseError;
                        Contents   = parser.Root;
                        return(sr.ReadToEnd());
                    }
                }
            }
        }