Beispiel #1
0
        public static Item ReadFrom(System.IO.BinaryReader reader)
        {
            switch (reader.ReadInt32())
            {
            case HealthPack.TAG:
                return(HealthPack.ReadFrom(reader));

            case Weapon.TAG:
                return(Weapon.ReadFrom(reader));

            case Mine.TAG:
                return(Mine.ReadFrom(reader));

            default:
                throw new System.Exception("Unexpected discriminant value");
            }
        }
Beispiel #2
0
        public static Item ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException(nameof(reader));
            }

            switch (reader.ReadInt32())
            {
            case HealthPack.TAG:
                return(HealthPack.ReadFrom(reader));

            case Weapon.TAG:
                return(Weapon.ReadFrom(reader));

            case Mine.TAG:
                return(new Mine());

            default:
                throw new System.Exception("Unexpected discriminant value");
            }
        }