using System; using System.Runtime.InteropServices; namespace System.Reflection.Emit { /// Represents the class that describes how to marshal a field from managed to unmanaged code. This class cannot be inherited. // Token: 0x0200021D RID: 541 [ComVisible(true)] [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead.")] [Serializable] public sealed class UnmanagedMarshal { // Token: 0x06001CE3 RID: 7395 RVA: 0x0006D294 File Offset: 0x0006B494 private UnmanagedMarshal(UnmanagedType maint, int cnt) { this.count = cnt; this.t = maint; this.tbase = maint; } // Token: 0x06001CE4 RID: 7396 RVA: 0x0006D2B4 File Offset: 0x0006B4B4 private UnmanagedMarshal(UnmanagedType maint, UnmanagedType elemt) { this.count = 0; this.t = maint; this.tbase = elemt; } /// Gets an unmanaged base type. This property is read-only. /// An UnmanagedType object. /// The unmanaged type is not an LPArray or a SafeArray. // Token: 0x1700052E RID: 1326 // (get) Token: 0x06001CE5 RID: 7397 RVA: 0x0006D2D4 File Offset: 0x0006B4D4 public UnmanagedType BaseType { get { if (this.t == UnmanagedType.LPArray || this.t == UnmanagedType.SafeArray) { throw new ArgumentException(); } return this.tbase; } } /// Gets a number element. This property is read-only. /// An integer indicating the element count. /// The argument is not an unmanaged element count. // Token: 0x1700052F RID: 1327 // (get) Token: 0x06001CE6 RID: 7398 RVA: 0x0006D308 File Offset: 0x0006B508 public int ElementCount { get { return this.count; } } /// Indicates an unmanaged type. This property is read-only. /// An object. // Token: 0x17000530 RID: 1328 // (get) Token: 0x06001CE7 RID: 7399 RVA: 0x0006D310 File Offset: 0x0006B510 public UnmanagedType GetUnmanagedType { get { return this.t; } } /// Gets a GUID. This property is read-only. /// A object. /// The argument is not a custom marshaler. // Token: 0x17000531 RID: 1329 // (get) Token: 0x06001CE8 RID: 7400 RVA: 0x0006D318 File Offset: 0x0006B518 public Guid IIDGuid { get { return new Guid(this.guid); } } /// Specifies a fixed-length array (ByValArray) to marshal to unmanaged code. /// An object. /// The number of elements in the fixed-length array. /// The argument is not a simple native type. // Token: 0x06001CE9 RID: 7401 RVA: 0x0006D328 File Offset: 0x0006B528 public static UnmanagedMarshal DefineByValArray(int elemCount) { return new UnmanagedMarshal(UnmanagedType.ByValArray, elemCount); } /// Specifies a string in a fixed array buffer (ByValTStr) to marshal to unmanaged code. /// An object. /// The number of elements in the fixed array buffer. /// The argument is not a simple native type. // Token: 0x06001CEA RID: 7402 RVA: 0x0006D334 File Offset: 0x0006B534 public static UnmanagedMarshal DefineByValTStr(int elemCount) { return new UnmanagedMarshal(UnmanagedType.ByValTStr, elemCount); } /// Specifies an LPArray to marshal to unmanaged code. The length of an LPArray is determined at runtime by the size of the actual marshaled array. /// An object. /// The unmanaged type to which to marshal the array. /// The argument is not a simple native type. // Token: 0x06001CEB RID: 7403 RVA: 0x0006D340 File Offset: 0x0006B540 public static UnmanagedMarshal DefineLPArray(UnmanagedType elemType) { return new UnmanagedMarshal(UnmanagedType.LPArray, elemType); } /// Specifies a SafeArray to marshal to unmanaged code. /// An object. /// The base type or the UnmanagedType of each element of the array. /// The argument is not a simple native type. // Token: 0x06001CEC RID: 7404 RVA: 0x0006D34C File Offset: 0x0006B54C public static UnmanagedMarshal DefineSafeArray(UnmanagedType elemType) { return new UnmanagedMarshal(UnmanagedType.SafeArray, elemType); } /// Specifies a given type that is to be marshaled to unmanaged code. /// An object. /// The unmanaged type to which the type is to be marshaled. /// The argument is not a simple native type. // Token: 0x06001CED RID: 7405 RVA: 0x0006D358 File Offset: 0x0006B558 public static UnmanagedMarshal DefineUnmanagedMarshal(UnmanagedType unmanagedType) { return new UnmanagedMarshal(unmanagedType, unmanagedType); } // Token: 0x06001CEE RID: 7406 RVA: 0x0006D364 File Offset: 0x0006B564 public static UnmanagedMarshal DefineCustom(Type typeref, string cookie, string mtype, Guid id) { UnmanagedMarshal unmanagedMarshal = new UnmanagedMarshal(UnmanagedType.CustomMarshaler, UnmanagedType.CustomMarshaler); unmanagedMarshal.mcookie = cookie; unmanagedMarshal.marshaltype = mtype; unmanagedMarshal.marshaltyperef = typeref; if (id == Guid.Empty) { unmanagedMarshal.guid = string.Empty; } else { unmanagedMarshal.guid = id.ToString(); } return unmanagedMarshal; } // Token: 0x06001CEF RID: 7407 RVA: 0x0006D3C0 File Offset: 0x0006B5C0 internal static UnmanagedMarshal DefineLPArrayInternal(UnmanagedType elemType, int sizeConst, int sizeParamIndex) { return new UnmanagedMarshal(UnmanagedType.LPArray, elemType) { count = sizeConst, param_num = sizeParamIndex, has_size = true }; } // Token: 0x06001CF0 RID: 7408 RVA: 0x0006D3EC File Offset: 0x0006B5EC internal MarshalAsAttribute ToMarshalAsAttribute() { MarshalAsAttribute marshalAsAttribute = new MarshalAsAttribute(this.t); marshalAsAttribute.ArraySubType = this.tbase; marshalAsAttribute.MarshalCookie = this.mcookie; marshalAsAttribute.MarshalType = this.marshaltype; marshalAsAttribute.MarshalTypeRef = this.marshaltyperef; if (this.count == -1) { marshalAsAttribute.SizeConst = 0; } else { marshalAsAttribute.SizeConst = this.count; } if (this.param_num == -1) { marshalAsAttribute.SizeParamIndex = 0; } else { marshalAsAttribute.SizeParamIndex = (short)this.param_num; } return marshalAsAttribute; } // Token: 0x040009CA RID: 2506 private int count; // Token: 0x040009CB RID: 2507 private UnmanagedType t; // Token: 0x040009CC RID: 2508 private UnmanagedType tbase; // Token: 0x040009CD RID: 2509 private string guid; // Token: 0x040009CE RID: 2510 private string mcookie; // Token: 0x040009CF RID: 2511 private string marshaltype; // Token: 0x040009D0 RID: 2512 private Type marshaltyperef; // Token: 0x040009D1 RID: 2513 private int param_num; // Token: 0x040009D2 RID: 2514 private bool has_size; } }