/// <summary>
        /// Serializes a packet and returns a memory stream containing streamed bytes (position is start of serialization)
        /// </summary>
        public static MemoryStream SerializePacket(this Serialization serialization, Packet p)
        {
            switch (serialization)
            {
            case Serialization.NATIVE:
                return(NativeSerialization.SerializePacket(p));

            case Serialization.PROTOBUF:
                return(ProtobufSerialization.SerializePacket(p));
            }
            throw new ArgumentException("Unrecognized serialization method: " + serialization);
        }
        /// <summary>
        /// Deserializes a packet from a stream
        /// </summary>
        public static Packet DeserializePacket(this Serialization serialization, Stream from)
        {
            switch (serialization)
            {
            case Serialization.NATIVE:
                return(NativeSerialization.DeserializePacket(from));

            case Serialization.PROTOBUF:
                return(ProtobufSerialization.DeserializePacket(from));
            }
            throw new ArgumentException("Unrecognized serialization method: " + serialization);
        }
        /// <summary>
        /// Sets a packet up before serialization. Mainly for serialization methods light on type metadata (protobuf-net...)
        /// Designed to be used solely by the packet class
        /// </summary>
        internal static bool SetupPacket_PreSerialization(this Serialization serialization, ref object[] contents)
        {
            if (contents == null)
            {
                return(true);
            }

            switch (serialization)
            {
            case Serialization.NATIVE:
                return(true);

            case Serialization.PROTOBUF:
                return(ProtobufSerialization.SetupPacket_PreSerialization(ref contents));
            }
            throw new ArgumentException("Unrecognized serialization method: " + serialization);
        }