Exemple #1
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);
        }