public bool tryVectorPrice(
string name,
ushort fid,
ref MamaPrice[] result)
{
// Returns
bool ret = false;
// The following arraylist wil contain all of the prices
ArrayList retPrices = new ArrayList();
// Enusre that the native message has been created
EnsurePeerCreated();
// Get the strings from the native message
IntPtr globalMemoryPointer = IntPtr.Zero;
uint numberElements = 0;
int code = NativeMethods.mamaMsg_getVectorPrice(nativeHandle, name, fid, ref globalMemoryPointer, ref numberElements);
if ((MamaStatus.mamaStatus)code == MamaStatus.mamaStatus.MAMA_STATUS_OK)
{
// Only continue if there are actually any prices in the array
if (numberElements > 0)
{
// Create a new array of pointers to hold the native price pointers
IntPtr[] nativePriceArray = new IntPtr[numberElements];
// Copy the entire array over
Marshal.Copy(globalMemoryPointer, nativePriceArray, 0, (int)numberElements);
// Extract each price, one at a time
foreach (IntPtr nextNativePrice in nativePriceArray)
{
retPrices.Add(new MamaPrice(nextNativePrice));
}
}
// The function has succeeded even if there were 0 strings
ret = true;
}
// Return the array of strings
result = (MamaPrice[])retPrices.ToArray(typeof(MamaPrice));
return ret;
}