Esempio n. 1
0
        public static IBinarySerializable UnpackObject(BinaryReader reader)
        {
            string typeName = reader.ReadString();

            if (typeName.Length == 0)
            {
                return(null);
            }

            Type findedType = null;

            if (registereredTypes.ContainsKey(typeName))
            {
                findedType = registereredTypes[typeName];
            }
            else
            {
                throw new Exception("Попытка распаковать неизвестный тип");
            }

            IBinarySerializable result = (IBinarySerializable)Activator.CreateInstance(findedType);

            result.Unpack(reader);
            return(result);
        }