コード例 #1
0
ファイル: PPFilePreprocessor.cs プロジェクト: ericstj/cli
        public static void Preprocess(Stream input, Stream output, IDictionary<string, string> parameters)
        {
            string text;
            using (var streamReader = new StreamReader(input))
            {
                text = streamReader.ReadToEnd();
            }
            var tokenizer = new PPFileTokenizer(text);
            using (var streamWriter = new StreamWriter(output))
            {
                while (true)
                {
                    var token = tokenizer.Read();
                    if (token == null)
                    {
                        break;
                    }

                    if (token.Category == PPFileTokenizer.TokenCategory.Variable)
                    {
                        var replaced = ReplaceToken(token.Value, parameters);
                        streamWriter.Write(replaced);
                    }
                    else
                    {
                        streamWriter.Write(token.Value);
                    }
                }
            }
        }
コード例 #2
0
ファイル: PPFilePreprocessor.cs プロジェクト: singhsarab/cli
        public static void Preprocess(Stream input, Stream output, IDictionary <string, string> parameters)
        {
            string text;

            using (var streamReader = new StreamReader(input))
            {
                text = streamReader.ReadToEnd();
            }
            var tokenizer = new PPFileTokenizer(text);

            using (var streamWriter = new StreamWriter(output))
            {
                while (true)
                {
                    var token = tokenizer.Read();
                    if (token == null)
                    {
                        break;
                    }

                    if (token.Category == PPFileTokenizer.TokenCategory.Variable)
                    {
                        var replaced = ReplaceToken(token.Value, parameters);
                        streamWriter.Write(replaced);
                    }
                    else
                    {
                        streamWriter.Write(token.Value);
                    }
                }
            }
        }