Wombat.MamaMsg.tryVectorPrice C# (CSharp) Метод

tryVectorPrice() публичный Метод

Try to get a vector of prices.
public tryVectorPrice ( string name, ushort fid, MamaPrice &result ) : bool
name string /// The field name, can be null or blank if the field Id is supplied. ///
fid ushort /// The field id, can be 0 if the name is specified and field names are turned on. ///
result MamaPrice /// To return the array of prices. ///
Результат bool
        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;
        }

Same methods

MamaMsg::tryVectorPrice ( MamaFieldDescriptor descriptor, MamaPrice &result ) : bool
MamaMsg