Exemple #1
0
        public static string NumberLines(string s)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }
            StringReader stringReader = new StringReader(s);
            StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);
            int          num          = 1;

            StringUtils.ActionTextReaderLine(stringReader, stringWriter, (TextWriter tw, string line) => {
                tw.Write(num.ToString(CultureInfo.InvariantCulture).PadLeft(4));
                tw.Write(". ");
                tw.Write(line);
                num++;
            });
            return(stringWriter.ToString());
        }
Exemple #2
0
        public static string Indent(string s, int indentation, char indentChar)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }
            if (indentation <= 0)
            {
                throw new ArgumentException("Must be greater than zero.", "indentation");
            }
            StringReader stringReader = new StringReader(s);
            StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            StringUtils.ActionTextReaderLine(stringReader, stringWriter, (TextWriter tw, string line) => {
                tw.Write(new string(indentChar, indentation));
                tw.Write(line);
            });
            return(stringWriter.ToString());
        }
Exemple #3
0
        public static string NumberLines(string s)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }
            StringReader textReader   = new StringReader(s);
            StringWriter stringWriter = new StringWriter(CultureInfo.get_InvariantCulture());
            int          lineNumber   = 1;

            StringUtils.ActionTextReaderLine(textReader, stringWriter, delegate(TextWriter tw, string line)
            {
                tw.Write(lineNumber.ToString(CultureInfo.get_InvariantCulture()).PadLeft(4));
                tw.Write(". ");
                tw.Write(line);
                lineNumber++;
            });
            return(stringWriter.ToString());
        }