Пример #1
0
        private object ReadStringTypeValue(RSBinaryReader _binaryReader, out Type _objectType)
        {
            // Get object type
            _objectType = typeof(string);

            // Get object value
            return(_binaryReader.ReadString());
        }
        internal void ReadTypeMetaData(RSBinaryReader _binaryReader, BinaryElement _binaryElement)
        {
            // Read assembly info
            if (_binaryElement == BinaryElement.ASSEMBLY)
            {
                UInt32   _assemblyID       = _binaryReader.ReadUInt32();
                string   _assemblyFullName = _binaryReader.ReadString();
                Assembly _assembly         = Assembly.Load(_assemblyFullName);

                if (_assembly == null)
                {
                    throw new Exception(string.Format("[RS] Couldnt load assembly with name={0}.", _assemblyFullName));
                }

                // Add assembly info to cache
                m_cachedAssemblies.Add(_assembly, _assemblyID);

                // Read next element
                _binaryElement = _binaryReader.ReadBinaryElement();
            }

            // Read type info
            if (_binaryElement == BinaryElement.TYPE)
            {
                UInt32   _assemblyID   = _binaryReader.ReadUInt32();
                UInt32   _typeID       = _binaryReader.ReadUInt32();
                string   _typeFullName = _binaryReader.ReadString();
                Assembly _assembly     = GetAssembly(_assemblyID);

                if (_assembly == null)
                {
                    throw new Exception(string.Format("[RS] Assembly with ID={0} couldnt be found.", _assemblyID));
                }

                Type _newType = _assembly.GetType(_typeFullName, true);

                // Add type info to cache
                m_cachedObjectTypes.Add(_newType, _typeID);
            }
        }
Пример #3
0
        private void ReadSerializationContainer(RSBinaryReader _binaryReader, ref Dictionary <string, RuntimeSerializationEntry> _container)
        {
            int _memberCount = _binaryReader.ReadInt32();
            int _iter        = 0;

            while (_iter < _memberCount)
            {
                // Get property name and type
                string _pName = _binaryReader.ReadString();
                Type   _pType;
                object _pValue = ReadObjectValue(_binaryReader, out _pType);

                // Add new serialization entry
                _container.Add(_pName, new RuntimeSerializationEntry(_pName, _pValue, _pType));

                // Increment
                _iter++;
            }
        }
        private object ReadStringTypeValue(RSBinaryReader _binaryReader, out Type _objectType)
        {
            // Get object type
            _objectType					= typeof(string);

            // Get object value
            return _binaryReader.ReadString();
        }
        private void ReadSerializationContainer(RSBinaryReader _binaryReader, ref Dictionary<string, RuntimeSerializationEntry> _container)
        {
            int		_memberCount	= _binaryReader.ReadInt32();
            int		_iter			= 0;

            while (_iter < _memberCount)
            {
                // Get property name and type
                string	_pName		= _binaryReader.ReadString();
                Type	_pType;
                object	_pValue		= ReadObjectValue(_binaryReader, out _pType);

                // Add new serialization entry
                _container.Add(_pName, new RuntimeSerializationEntry(_pName, _pValue, _pType));

                // Increment
                _iter++;
            }
        }
        internal void ReadTypeMetaData(RSBinaryReader _binaryReader, BinaryElement _binaryElement)
        {
            // Read assembly info
            if (_binaryElement == BinaryElement.ASSEMBLY)
            {
                UInt32 		_assemblyID			= _binaryReader.ReadUInt32();
                string 		_assemblyFullName	= _binaryReader.ReadString();
                Assembly 	_assembly			= Assembly.Load(_assemblyFullName);

                if (_assembly == null)
                    throw new Exception(string.Format("[RS] Couldnt load assembly with name={0}.", _assemblyFullName));

                // Add assembly info to cache
                m_cachedAssemblies.Add(_assembly, _assemblyID);

                // Read next element
                _binaryElement					= _binaryReader.ReadBinaryElement();
            }

            // Read type info
            if (_binaryElement == BinaryElement.TYPE)
            {
                UInt32 		_assemblyID			= _binaryReader.ReadUInt32();
                UInt32 		_typeID				= _binaryReader.ReadUInt32();
                string 		_typeFullName		= _binaryReader.ReadString();
                Assembly 	_assembly			= GetAssembly(_assemblyID);

                if (_assembly == null)
                    throw new Exception(string.Format("[RS] Assembly with ID={0} couldnt be found.", _assemblyID));

                Type 		_newType			= _assembly.GetType(_typeFullName, true);

                // Add type info to cache
                m_cachedObjectTypes.Add(_newType, _typeID);
            }
        }