//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 loyalsoft. All rights reserved.
// Homepage: http://www.game7000.com/
// Feedback: http://www.game7000.com/
//------------------------------------------------------------
namespace GameFramework.Download
{
///
/// 下载代理辅助器更新数据流事件。
///
public sealed class DownloadAgentHelperUpdateBytesEventArgs : GameFrameworkEventArgs
{
private byte[] m_Bytes;
///
/// 初始化下载代理辅助器更新数据流事件的新实例。
///
public DownloadAgentHelperUpdateBytesEventArgs()
{
m_Bytes = null;
Offset = 0;
Length = 0;
}
///
/// 获取数据流的偏移。
///
public int Offset
{
get;
private set;
}
///
/// 获取数据流的长度。
///
public int Length
{
get;
private set;
}
///
/// 创建下载代理辅助器更新数据流事件。
///
/// 下载的数据流。
/// 数据流的偏移。
/// 数据流的长度。
/// 创建的下载代理辅助器更新数据流事件。
public static DownloadAgentHelperUpdateBytesEventArgs Create(byte[] bytes, int offset, int length)
{
if (bytes == null)
{
throw new GameFrameworkException("Bytes is invalid.");
}
if (offset < 0 || offset >= bytes.Length)
{
throw new GameFrameworkException("Offset is invalid.");
}
if (length <= 0 || offset + length > bytes.Length)
{
throw new GameFrameworkException("Length is invalid.");
}
DownloadAgentHelperUpdateBytesEventArgs downloadAgentHelperUpdateBytesEventArgs = ReferencePool.Acquire();
downloadAgentHelperUpdateBytesEventArgs.m_Bytes = bytes;
downloadAgentHelperUpdateBytesEventArgs.Offset = offset;
downloadAgentHelperUpdateBytesEventArgs.Length = length;
return downloadAgentHelperUpdateBytesEventArgs;
}
///
/// 清理下载代理辅助器更新数据流事件。
///
public override void Clear()
{
m_Bytes = null;
Offset = 0;
Length = 0;
}
///
/// 获取下载的数据流。
///
public byte[] GetBytes()
{
return m_Bytes;
}
}
}