Beispiel #1
0
 public static IEnumerable <object> FromByteMultiple(this ITypeMapper mapper, IEnumerable <byte[]> source, Func <object> factory)
 {
     foreach (var buffer in source)
     {
         var target = factory();
         mapper.FromByte(buffer, 0, target);
         yield return(target);
     }
 }
Beispiel #2
0
        public static IEnumerable <object> FromByteMultiple(this ITypeMapper mapper, byte[] buffer, int start, Func <object> factory)
        {
            while (start + mapper.Size <= buffer.Length)
            {
                var target = factory();
                mapper.FromByte(buffer, start, target);
                yield return(target);

                start += buffer.Length;
            }
        }
Beispiel #3
0
        public static IEnumerable <T> FromStreamMultiple <T>(this ITypeMapper <T> mapper, Stream stream, Func <T> factory)
        {
            var buffer = new byte[mapper.Size];

            while (stream.Read(buffer, 0, buffer.Length) == buffer.Length)
            {
                var target = factory();
                mapper.FromByte(buffer, 0, target);
                yield return(target);
            }
        }
Beispiel #4
0
        public static bool FromStream <T>(this ITypeMapper <T> mapper, Stream stream, T target)
        {
            var buffer = new byte[mapper.Size];

            if (stream.Read(buffer, 0, buffer.Length) != buffer.Length)
            {
                return(false);
            }

            mapper.FromByte(buffer, 0, target);
            return(true);
        }
Beispiel #5
0
        //--------------------------------------------------------------------------------
        // FromByte NonGeneric
        //--------------------------------------------------------------------------------

        public static void FromByte(this ITypeMapper mapper, byte[] buffer, object target)
        {
            mapper.FromByte(buffer, 0, target);
        }
Beispiel #6
0
        //--------------------------------------------------------------------------------
        // FromByte
        //--------------------------------------------------------------------------------

        public static void FromByte <T>(this ITypeMapper <T> mapper, byte[] buffer, T target)
        {
            mapper.FromByte(buffer, 0, target);
        }
 public void FromByte()
 {
     mapper.FromByte(allocatedBuffer, 0, allocatedData);
 }