Ejemplo n.º 1
0
        public static ListValue Instantiate(TypeManager typeManager, Type fullType, PainlessBinaryReader reader)
        {
            int   listLength = reader.ReadInt32();
            IList list       = (IList)Activator.CreateInstance(fullType, listLength);

            return(new ListValue(fullType, list, listLength));
        }
Ejemplo n.º 2
0
 void ReadIntoArray(PainlessBinaryReader reader, IList destination)
 {
     for (int index = 0; index < _arrayLength; ++index)
     {
         destination[index] = reader.ReadPainlessBinaryObject(_elementType);
     }
 }
Ejemplo n.º 3
0
        public static ArrayValue Instantiate(TypeManager typeManager, Type fullType, PainlessBinaryReader reader)
        {
            int   arrayLength = reader.ReadInt32();
            IList array       = (IList)Activator.CreateInstance(fullType, arrayLength);

            return(new ArrayValue(fullType, array, arrayLength));
        }
Ejemplo n.º 4
0
        public void Read(PainlessBinaryReader reader)
        {
            ReadUnderlyingTypeFunction readFunction = _readFunctions[_underlyingType];
            object underlyingValue = readFunction(reader);

            Value = Enum.ToObject(_enumType, underlyingValue);
        }
Ejemplo n.º 5
0
        internal ISerializableValue Instantiate(Type type, PainlessBinaryReader reader)
        {
            RegisteredType     registeredType = GetRegisteredType(type);
            ISerializableValue value          = registeredType.Instantiator(this, type, reader);

            return(value);
        }
Ejemplo n.º 6
0
 public void Read(PainlessBinaryReader reader)
 {
     for (int index = 0; index < _listLength; ++index)
     {
         object value = reader.ReadPainlessBinaryObject(_contentType);
         _list.Add(value);
     }
 }
Ejemplo n.º 7
0
        public void Read(PainlessBinaryReader reader)
        {
            if (_rank == 1)
            {
                ReadIntoArray(reader, _array);
                return;
            }

            throw new NotImplementedException();
        }
Ejemplo n.º 8
0
        Type ResolveGenericArguments(PainlessBinaryReader reader, Type baseType, int numGenericParameters)
        {
            Type[] genericArguments = new Type[numGenericParameters];

            for (int index = 0; index < numGenericParameters; ++index)
            {
                genericArguments[index] = reader.ReadNextType();
            }

            return(baseType.MakeGenericType(genericArguments));
        }
Ejemplo n.º 9
0
        public Type Read(PainlessBinaryReader reader)
        {
            int numGenericParameters = CountNumberGenericParameters(_baseType);

            if (numGenericParameters == 0)
            {
                return(_baseType);
            }

            return(ResolveGenericArguments(reader, _baseType, numGenericParameters));
        }
Ejemplo n.º 10
0
        public Type Read(PainlessBinaryReader reader)
        {
            Type elementType = reader.ReadNextType();
            int  rank        = reader.ReadInt32();

            if (rank == 1)
            {
                return(elementType.MakeArrayType());
            }

            return(elementType.MakeArrayType(rank));
        }
Ejemplo n.º 11
0
        static T DeserializeFilePayload <T>(PainlessBinaryReader reader)
        {
            Type fileType = reader.ReadNextType();

            if (fileType != typeof(T))
            {
                throw new DifferentFileTypeException(typeof(T), fileType);
            }

            object deserializedObject = reader.ReadPainlessBinaryObject(typeof(T));

            return((T)deserializedObject);
        }
Ejemplo n.º 12
0
 public SerializationFile <T> DeserializeFile <T>(Stream dataStream)
 {
     using (StreamWrapper streamWrapper = new StreamWrapper(dataStream))
     {
         using (PainlessBinaryReader reader = new PainlessBinaryReader(streamWrapper, _typeManager, HashBaseValue, HashMultiplicationConstant))
         {
             T payload = DeserializeFilePayload <T>(reader);
             return(new SerializationFile <T>
             {
                 Payload = payload
             });
         }
     }
 }
Ejemplo n.º 13
0
        public void Read(PainlessBinaryReader reader)
        {
            reader.PushCompoundingHash();

            foreach (SerializedMember member in _members)
            {
                object memberValue = reader.ReadPainlessBinaryObject(member.Type);
                member.SetValue(Value, memberValue);
            }

            int computedHash = reader.PopCompoundingHash();
            int readHash     = reader.ReadInt32();

            if (computedHash != readHash)
            {
                throw new DataIntegrityQuestionableException(computedHash, readHash);
            }
        }
Ejemplo n.º 14
0
 public void Read(PainlessBinaryReader reader)
 {
     _value = _readWriteOperations.ReadFunction(reader);
 }
Ejemplo n.º 15
0
 public void Read(PainlessBinaryReader reader)
 {
     Value = reader.ReadPainlessBinaryObject(_contentType);
 }
Ejemplo n.º 16
0
        public static ReflectedClassValue Instantiate(TypeManager typeManager, Type fullType, PainlessBinaryReader reader)
        {
            object value = Activator.CreateInstance(fullType);

            return(new ReflectedClassValue(fullType, value));
        }
Ejemplo n.º 17
0
 public static NullableValue Instantiate(TypeManager typeManager, Type fullType, PainlessBinaryReader reader)
 {
     return(new NullableValue(fullType, null));
 }