Pchp.Library.Streams.TextElement.GetBytes C# (CSharp) Method

GetBytes() private method

private GetBytes ( ) : byte[]
return byte[]
        internal byte[] GetBytes() => (byte[])_data;

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Split a <see cref="String"/> or <see cref="PhpBytes"/> to "upto" bytes at left and the rest or <c>null</c> at right.
 /// </summary>
 private static void SplitData(TextElement data, int upto, out TextElement left, out TextElement right)
 {
     Debug.Assert(upto >= 0);
     //if (this.IsText)
     if (data.IsText)
     {
         string s = data.GetText();
         if (upto < s.Length - 1)
         {
             left = new TextElement(s.Substring(0, upto + 1));
             right = new TextElement(s.Substring(upto + 2));
         }
         else
         {
             left = data;
             right = TextElement.Null;
         }
     }
     else
     {
         Debug.Assert(data.IsBinary);
         var bin = data.GetBytes();
         if (upto < bin.Length - 1)
         {
             byte[] l = new byte[upto + 1], r = new byte[bin.Length - upto - 1];
             Array.Copy(bin, 0, l, 0, upto + 1);
             Array.Copy(bin, upto + 1, r, 0, bin.Length - upto - 1);
             left = new TextElement(l);
             right = new TextElement(r);
         }
         else
         {
             left = data;
             right = TextElement.Null;
         }
     }
 }
All Usage Examples Of Pchp.Library.Streams.TextElement::GetBytes