IPackage BuildPackage(MemoryStream stream, int index, Type packageType)
{
try
{
return GetPackage(stream, index, packageType);
}
catch (OverflowException ex)
{
if (ThrowWhenInvalid)
{
throw new InvalidPacketException(ex);
}
else
{
//Receiving this means the type is not correct.
ConversionException = ex;
ConversionFailed = true;
}
}
catch (Exception ex)
{
if (ThrowWhenInvalid)
{
throw new InvalidPacketException(ex);
}
else
{
//Receiving this probably means a type is not correct--but could mean something else.
ConversionException = ex;
ConversionFailed = true;
}
}
return null;
}
internal static IPackage GetPackage(MemoryStream stream, int index, Type packageType)