Nexus.Client.Games.Morrowind.PluginManagement.Boss.StringArrayManualMarshaler.MarshalNativeToManaged C# (CSharp) Method

MarshalNativeToManaged() public method

Marshals the given pointer to a string.
public MarshalNativeToManaged ( IntPtr pNativeData, Int32 p_intSize ) : string[]
pNativeData System.IntPtr The pointer to the data to marshal to a string.
p_intSize System.Int32 The length of the array to marshal.
return string[]
		public string[] MarshalNativeToManaged(IntPtr pNativeData, Int32 p_intSize)
		{
			if (pNativeData == IntPtr.Zero)
				return null;

			string[] strStrings = new string[p_intSize];
			for (Int32 i = 0; i < p_intSize; i++)
			{
				IntPtr ptrString = Marshal.ReadIntPtr(pNativeData, i * IntPtr.Size);
				List<byte> lstString = StringMarshaler.GetStringBytes(ptrString, m_encEncoding);
				strStrings[i] = m_encEncoding.GetString(lstString.ToArray(), 0, lstString.Count);
			}
			return strStrings;
		}

Usage Example

 /// <summary>
 /// Marshal the given pointer to an array of plugins.
 /// </summary>
 /// <remarks>
 /// This adjusts the plugin paths to be in the format expected by the  mod manager.
 /// </remarks>
 /// <param name="p_ptrPluginArray">The pointer to the array of plugin names to marshal.</param>
 /// <param name="p_uintLength">the length of the array to marshal.</param>
 /// <returns>The array of plugins names pointed to by the given pointer.</returns>
 protected string[] MarshalPluginArray(IntPtr p_ptrPluginArray, UInt32 p_uintLength)
 {
     if (p_ptrPluginArray == IntPtr.Zero)
     {
         return(null);
     }
     string[] strPlugins = null;
     using (StringArrayManualMarshaler ammMarshaler = new StringArrayManualMarshaler("UTF8"))
         strPlugins = ammMarshaler.MarshalNativeToManaged(p_ptrPluginArray, Convert.ToInt32(p_uintLength));
     for (Int32 i = strPlugins.Length - 1; i >= 0; i--)
     {
         strPlugins[i] = Path.Combine(GameMode.PluginDirectory, strPlugins[i]);
     }
     return(strPlugins);
 }
All Usage Examples Of Nexus.Client.Games.Morrowind.PluginManagement.Boss.StringArrayManualMarshaler::MarshalNativeToManaged