internal override object ReadObjectValue(RSBinaryReader _binaryReader, out Type _objectType, object _object = null)
        {
            BinaryElement _curBinaryElement;

            while ((_curBinaryElement = _binaryReader.ReadBinaryElement()) != BinaryElement.OBJECT_DATA)
            {
                TypeMetadata.ReadTypeMetaData(_binaryReader, _curBinaryElement);
            }

            if (_curBinaryElement != BinaryElement.OBJECT_DATA)
            {
                throw new Exception(string.Format("[RS] Parsing error. BinaryElement={0}.", _curBinaryElement));
            }

            // Deserialize based on value
            eTypeTag _typeTag     = _binaryReader.ReadTypeTag();
            object   _objectValue = null;

            switch (_typeTag)
            {
            case eTypeTag.NULL:
            case eTypeTag.UNSUPPORTED:
                _objectType  = null;
                _objectValue = null;
                break;

            case eTypeTag.PRIMITIVE:
                _objectValue = ReadPrimitiveTypeValue(_binaryReader, out _objectType);
                break;

            case eTypeTag.STRUCT:
                _objectValue = ReadStructTypeValue(_binaryReader, out _objectType, _object);
                break;

            case eTypeTag.STRING:
                _objectValue = ReadStringTypeValue(_binaryReader, out _objectType);
                break;

            case eTypeTag.CLASS:
                _objectValue = ReadClassTypeValue(_binaryReader, out _objectType, _object);
                break;

            case eTypeTag.OBJECT_REFERENCE:
                _objectValue = ReadObjectReferenceValue(_binaryReader, out _objectType);
                break;

            default:
                throw new Exception(string.Format("[RS] Unsupported type tag{0}. For more supported types, Purchase full version http://u3d.as/g8b", _typeTag));
            }

            return(_objectValue);
        }
        internal override object ReadObjectValue(RSBinaryReader _binaryReader, out Type _objectType, object _object = null)
        {
            BinaryElement _curBinaryElement;

            while ((_curBinaryElement = _binaryReader.ReadBinaryElement()) != BinaryElement.OBJECT_DATA)
            {
                TypeMetadata.ReadTypeMetaData(_binaryReader, _curBinaryElement);
            }

            if (_curBinaryElement != BinaryElement.OBJECT_DATA)
                throw new Exception(string.Format("[RS] Parsing error. BinaryElement={0}.", _curBinaryElement));

            // Deserialize based on value
            eTypeTag _typeTag	= _binaryReader.ReadTypeTag();
            object _objectValue	= null;

            switch (_typeTag)
            {
            case eTypeTag.NULL:
            case eTypeTag.UNSUPPORTED:
                _objectType		= null;
                _objectValue	= null;
                break;

            case eTypeTag.PRIMITIVE:
                _objectValue	= ReadPrimitiveTypeValue(_binaryReader, out _objectType);
                break;

            case eTypeTag.STRUCT:
                _objectValue	= ReadStructTypeValue(_binaryReader, out _objectType, _object);
                break;

            case eTypeTag.STRING:
                _objectValue	= ReadStringTypeValue(_binaryReader, out _objectType);
                break;

            case eTypeTag.CLASS:
                _objectValue	= ReadClassTypeValue(_binaryReader, out _objectType, _object);
                break;

            case eTypeTag.OBJECT_REFERENCE:
                _objectValue	= ReadObjectReferenceValue(_binaryReader, out _objectType);
                break;

            default:
                throw new Exception(string.Format("[RS] Unsupported type tag{0}. For more supported types, Purchase full version http://u3d.as/g8b", _typeTag));
            }

            return _objectValue;
        }
        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);
            }
        }
        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);
            }
        }