Ejemplo n.º 1
0
 public void ToFile(SaveFile lSaveFile)
 {
     foreach (SGFToken lSGFToken in Tokens)
         if (lSGFToken.Type != TokenType.DELETED)
             lSaveFile.Write(lSGFToken.ToString());
 }
Ejemplo n.º 2
0
        public bool Process()
        {
            BoardSize = DefaultBoardSize;
            ReadFile lInput = new ReadFile();

            if (string.IsNullOrEmpty(InputFileName))
                lInput.OpenConsole();
            else
                lInput.OpenFile(InputFileName);

            if (lInput.IsError())
                return SetErrorMessage(lInput);

            SGFTokens lTokens = SGFScanner.Tokenize(lInput);

            if (lTokens.IsError())
                return SetErrorMessage(lTokens);

            if (RemoveWhiteSpace)
                lTokens.RemoveAllWhiteSpace();

            lTokens.ProcessProperties(ProcessProperty);

            if (Pretty)
                lTokens.Pretty();

            SaveFile lOutput = new SaveFile();

            try
            {
                if (string.IsNullOrEmpty(OutputFileName))
                    lOutput.Create();
                else
                    lOutput.Create(OutputFileName);

                if (lOutput.IsOk())
                    lTokens.ToFile(lOutput);

                if (lOutput.IsError())
                    return SetErrorMessage(lOutput);
            }
            finally
            {
                lOutput.Close();
            }
            return true;
        }