示例#1
0
        /// <summary>
        /// Determines if the given string has non-whitespace characters in it
        /// </summary>
        public static bool HasNonWhitespace(Syntax.StringPart part)
        {
            var s = part.Source;
            var i = part.StartIndex;
            var l = i + part.Length;

            while (i < l)
            {
                if (!Utilities.IsWhitespace(s[i]))
                {
                    return(true);
                }

                i++;
            }

            return(false);
        }
示例#2
0
        public void Write(Syntax.StringPart value)
        {
            if (value.Length == 0)
            {
                return;
            }

            if (this.Buffer.Length < value.Length)
            {
                this.Buffer = new char[value.Length];
            }

            value.Source.CopyTo(value.StartIndex, this.Buffer, 0, value.Length);

            if (this._windowsNewLine)
            {
                var lastPos = value.StartIndex;
                var pos     = lastPos;
                var lastC   = this._last;

                while (-1 != (pos = value.Source.IndexOf('\n', pos, value.Length - pos + value.StartIndex)))
                {
                    lastC = pos == 0 ? this._last : value.Source[pos - 1];

                    if (lastC != '\r')
                    {
                        this._inner.Write(this.Buffer, lastPos - value.StartIndex, pos - lastPos);
                        this._inner.Write('\r');
                        lastPos = pos;
                    }

                    pos++;
                }

                this._inner.Write(this.Buffer, lastPos - value.StartIndex, value.Length - lastPos + value.StartIndex);
            }
            else
            {
                this._inner.Write(this.Buffer, 0, value.Length);
            }

            this._last = this.Buffer[value.Length - 1];
        }