Ejemplo n.º 1
0
        // Generic deserialization
        public T[] Deserialize()
        {
            // Read info about storage format
            ArrayStorageFormats format = (ArrayStorageFormats)SerializerStorage.ReadStorageFormatId(ArrayStorageBase.FormatIdSizeInBits);

            // Case: null Array
            if (format == ArrayStorageFormats.NullArray)
            {
                return(null);
            }

            // Case: empty Array
            if (format == ArrayStorageFormats.EmptyArray)
            {
                return(new T[0]);
            }

            // Restore array size
            Int32Serializer intSerializer = new Int32Serializer(SerializerStorage);
            Int32           arrayLength   = intSerializer.Deserialize();

            // Case: normal Array
            T[] outputArray = new T[arrayLength];

            // Deserialize all the elems
            for (int pos = 0; pos < arrayLength; pos++)
            {
                T value = m_ElemDeserializationFunc();
                outputArray[pos] = value;
            }

            // Return result
            return(outputArray);
        }
Ejemplo n.º 2
0
        // Generic deserialization
        private T[] DeserializeInternal(Action <int, T[]> arrayDeserializationAction)
        {
            // Read info about storage format
            ArrayStorageFormats format = (ArrayStorageFormats)SerializerStorage.ReadStorageFormatId(ArrayStorageBase.FormatIdSizeInBits);

            // Case: null Array
            if (format == ArrayStorageFormats.NullArray)
            {
                return(null);
            }

            // Case: empty Array
            if (format == ArrayStorageFormats.EmptyArray)
            {
                return(new T[0]);
            }

            // Restore array size
            Int32Serializer intSerializer = new Int32Serializer(SerializerStorage);
            Int32           arrayLength   = intSerializer.Deserialize();

            // Case: normal Array
            T[] outputArray = new T[arrayLength];

            // Deserialize array elements
            arrayDeserializationAction(arrayLength, outputArray);

            // Return result
            return(outputArray);
        }
Ejemplo n.º 3
0
 // Constructor that requires config case value
 public ArrayStorageBase(ArrayStorageFormats confCase, byte usedConfigBits) : base((byte)confCase, FormatIdSizeInBits, usedConfigBits)
 {
 }