private bool tryVectorMsgImpl(
string name,
ushort fid,
ref MamaMsg[] result,
bool throwOnError)
{
EnsurePeerCreated();
IntPtr array = IntPtr.Zero;
uint size = 0;
int code = NativeMethods.mamaMsg_getVectorMsg(nativeHandle,name,fid,ref array, ref size);
if ((MamaStatus.mamaStatus)code != MamaStatus.mamaStatus.MAMA_STATUS_OK)
{
if (throwOnError)
{
CheckResultCode(code);
}
else
{
return false;
}
}
MamaMsg[] ret;
if (size == 1)
{
if (tempMsgVector == null)
{
tempMsgVector = new MamaMsg[1];
tempMsgVector[0] = new MamaMsg();
tempMsgVector[0].SelfManageLifeTime(false);
}
ret = tempMsgVector;
ret[0].setNativeHandle(Marshal.ReadIntPtr(array));
}
else
{
ret = new MamaMsg[size];
for (int i = 0 ; i < size; i++)
{
ret[i] = new MamaMsg(Marshal.ReadIntPtr(array, i * Marshal.SizeOf(typeof(IntPtr))));
}
}
result = ret;
return true;
}