Esempio n. 1
0
        public static Text Create(Pointer pointer, char[] value, int offset = 0, int count = -1)
        {
            if (value == null)
            {
                return(default(Text));
            }
            if (count < 0)
            {
                count = value.Length - offset;
            }
            if (offset + count > value.Length)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            if (value.Length == 0)
            {
                // automatic nil pointer
                return((Text)pointer.AllocateList(ElementSize.OneByte, 1));
            }

            int byteLen = Textizer.Encoding.GetByteCount(value, offset, count);
            var ptr     = pointer.AllocateList(ElementSize.OneByte, byteLen + 1);

            Textizer.Write(ptr, value, offset, count);
            return((Text)ptr);
        }
Esempio n. 2
0
 public int AppendTo(TextWriter destination)
 {
     if (value != null)
     {
         destination.Write(value);
         return(value.Length);
     }
     return(Textizer.AppendTo(pointer, destination));
 }
Esempio n. 3
0
 public int AppendTo(StringBuilder destination)
 {
     if (value != null)
     {
         destination.Append(value);
         return(value.Length);
     }
     return(Textizer.AppendTo(pointer, destination));
 }
Esempio n. 4
0
 public static Text Create(Pointer pointer, System.Data.IDataRecord reader, int fieldIndex)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     if (fieldIndex < 0 || fieldIndex >= reader.FieldCount)
     {
         throw new ArgumentOutOfRangeException("fieldIndex");
     }
     return(Textizer.Create(pointer, reader, fieldIndex));
 }
Esempio n. 5
0
 public int GetCharCount()
 {
     return(value == null?Textizer.Count(pointer) : value.Length);
 }