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

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

Try to get a vector of strings (char*).
public tryVectorString ( string name, ushort fid, string &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 string /// To return the array of strings. ///
Результат bool
        public bool tryVectorString(
            string name,
            ushort fid,
            ref string[] result)
        {
            // Returns
            bool ret = false;

            // The following arraylist wil contain all of the strings
            ArrayList retStrings = 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_getVectorString(nativeHandle, name, fid, ref globalMemoryPointer, ref numberElements);
            if ((MamaStatus.mamaStatus)code == MamaStatus.mamaStatus.MAMA_STATUS_OK)
            {
                // Only continue if there are actually any strings in the array
                if (numberElements > 0)
                {
                    // Create a new array of pointers to hold the native string pointers
                    IntPtr[] nativeStringArray = new IntPtr[numberElements];

                    // Copy the entire array over
                    Marshal.Copy(globalMemoryPointer, nativeStringArray, 0, (int)numberElements);

                    // Extract each string, one at a time
                    foreach (IntPtr nextNativeString in nativeStringArray)
                    {
                        retStrings.Add(Marshal.PtrToStringAnsi(nextNativeString));
                    }
                }

                // The function has succeeded even if there were 0 strings
                ret = true;
            }

            // Return the array of strings
            result = (string[])retStrings.ToArray(typeof(string));

            return ret;
        }

Same methods

MamaMsg::tryVectorString ( MamaFieldDescriptor descriptor, string &result ) : bool
MamaMsg