コード例 #1
0
        /// <summary>
        /// Reads serialized data into an <see cref="ISerializableGameObject"/>
        /// from stream using a BinaryReader.
        /// </summary>
        public static void Read(
            BinaryReader reader,
            ISerializableGameObject gameObject)
        {
            SaveSerialization type = (SaveSerialization)reader.ReadByte();

            SaveSerializer serializer;

            switch (type)
            {
            case SaveSerialization.ExplicitTypes:
            default:
                serializer = new ExplicitSaveSerializer();
                break;

            case SaveSerialization.ImplicitTypes:
                throw new NotImplementedException();
            }

            serializer.ReadGameObject(reader, gameObject);
        }
コード例 #2
0
        /// <summary>
        /// Writes an <see cref="ISerializableGameObject"/> to stream using a
        /// BinaryWriter.
        /// </summary>
        /// <param name="type">The <see cref="SaveSerialization"/> method to use.</param>
        public static void Write(
            BinaryWriter writer,
            ISerializableGameObject gameObject,
            SaveSerialization type)
        {
            writer.Write((byte)type);

            SaveSerializer serializer;

            switch (type)
            {
            case SaveSerialization.ExplicitTypes:
            default:
                serializer = new ExplicitSaveSerializer();
                break;

            case SaveSerialization.ImplicitTypes:
                throw new NotImplementedException();
            }

            serializer.WriteGameObject(writer, gameObject.GetSaveData());
        }