Exemplo n.º 1
0
        /*private byte[] ConvertToByteArray(TType[] array)
         * {
         *      Span<TType> span = new Span<TType>(array);
         *
         *      return span.AsBytes();
         * }*/

        /// <inheritdoc />
        public override async Task <TType[]> ReadAsync(IWireStreamReaderStrategyAsync source)
        {
            int size = await SizeStrategyService.SizeAsync(source)
                       .ConfigureAwait(false);

            int byteCount = SizeOfType * size;

            byte[] bytes = await source.ReadBytesAsync(byteCount)
                           .ConfigureAwait(false);

            return(bytes.ReinterpretToArray <TType>());
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override async Task WriteAsync(TType[] value, IWireStreamWriterStrategyAsync dest)
        {
            if (dest == null)
            {
                throw new ArgumentNullException(nameof(dest));
            }

            int size = await SizeStrategyService.SizeAsync <TType[], TType>(value, dest)
                       .ConfigureAwait(false);

            //We no longer verify size thanks to PHANTASY STAR ONLINE. Thanks Sega. Sometimes we have to fake the size

            await dest.WriteAsync(value.Reinterpret())
            .ConfigureAwait(false);
        }