Opc.Ua.Com.ComUtils.GetVARIANTs C# (CSharp) Method

GetVARIANTs() public static method

Marshals an array objects into an unmanaged array of VARIANTs.
public static GetVARIANTs ( object values, bool preprocess ) : IntPtr
values object An array of the objects to be marshalled
preprocess bool Whether the objects should have troublesome types removed before marhalling.
return System.IntPtr
		public static IntPtr GetVARIANTs(object[] values, bool preprocess)
		{
			int count = (values != null)?values.Length:0;

			if (count <= 0)
			{
				return IntPtr.Zero;
			}

			IntPtr pValues = Marshal.AllocCoTaskMem(count*VARIANT_SIZE);

			IntPtr pos = pValues;

			for (int ii = 0; ii < count; ii++)
			{
				if (preprocess)
				{
					Marshal.GetNativeVariantForObject(GetVARIANT(values[ii]), pos);
				}
				else
				{
					Marshal.GetNativeVariantForObject(values[ii], pos);
				}

				pos = (IntPtr)(pos.ToInt64() + VARIANT_SIZE);
			}

			return pValues;
		}	

Same methods

ComUtils::GetVARIANTs ( IntPtr &pArray, int size, bool deallocate ) : object[]