266 lines
11 KiB
C#
266 lines
11 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Reflection.Emit
|
|
{
|
|
/// <summary>Creates or associates parameter information.</summary>
|
|
// Token: 0x02000211 RID: 529
|
|
[ComVisible(true)]
|
|
[ComDefaultInterface(typeof(_ParameterBuilder))]
|
|
[ClassInterface(ClassInterfaceType.None)]
|
|
public class ParameterBuilder : _ParameterBuilder
|
|
{
|
|
// Token: 0x06001BD5 RID: 7125 RVA: 0x00069B08 File Offset: 0x00067D08
|
|
internal ParameterBuilder(MethodBase mb, int pos, ParameterAttributes attributes, string strParamName)
|
|
{
|
|
this.name = strParamName;
|
|
this.position = pos;
|
|
this.attrs = attributes;
|
|
this.methodb = mb;
|
|
if (mb is DynamicMethod)
|
|
{
|
|
this.table_idx = 0;
|
|
}
|
|
else
|
|
{
|
|
this.table_idx = mb.get_next_table_index(this, 8, true);
|
|
}
|
|
}
|
|
|
|
/// <summary>Maps a set of names to a corresponding set of dispatch identifiers.</summary>
|
|
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
|
|
/// <param name="rgszNames">Passed-in array of names to be mapped.</param>
|
|
/// <param name="cNames">Count of the names to be mapped.</param>
|
|
/// <param name="lcid">The locale context in which to interpret the names.</param>
|
|
/// <param name="rgDispId">Caller-allocated array which receives the IDs corresponding to the names.</param>
|
|
/// <exception cref="T:System.NotImplementedException">The method is called late-bound using the COM IDispatch interface.</exception>
|
|
// Token: 0x06001BD6 RID: 7126 RVA: 0x00069B60 File Offset: 0x00067D60
|
|
void _ParameterBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>Retrieves the type information for an object, which can then be used to get the type information for an interface.</summary>
|
|
/// <param name="iTInfo">The type information to return.</param>
|
|
/// <param name="lcid">The locale identifier for the type information.</param>
|
|
/// <param name="ppTInfo">Receives a pointer to the requested type information object.</param>
|
|
/// <exception cref="T:System.NotImplementedException">The method is called late-bound using the COM IDispatch interface.</exception>
|
|
// Token: 0x06001BD7 RID: 7127 RVA: 0x00069B68 File Offset: 0x00067D68
|
|
void _ParameterBuilder.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>Retrieves the number of type information interfaces that an object provides (either 0 or 1).</summary>
|
|
/// <param name="pcTInfo">Points to a location that receives the number of type information interfaces provided by the object.</param>
|
|
/// <exception cref="T:System.NotImplementedException">The method is called late-bound using the COM IDispatch interface.</exception>
|
|
// Token: 0x06001BD8 RID: 7128 RVA: 0x00069B70 File Offset: 0x00067D70
|
|
void _ParameterBuilder.GetTypeInfoCount(out uint pcTInfo)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>Provides access to properties and methods exposed by an object.</summary>
|
|
/// <param name="dispIdMember">Identifies the member.</param>
|
|
/// <param name="riid">Reserved for future use. Must be IID_NULL.</param>
|
|
/// <param name="lcid">The locale context in which to interpret arguments.</param>
|
|
/// <param name="wFlags">Flags describing the context of the call.</param>
|
|
/// <param name="pDispParams">Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays.</param>
|
|
/// <param name="pVarResult">Pointer to the location where the result is to be stored.</param>
|
|
/// <param name="pExcepInfo">Pointer to a structure that contains exception information.</param>
|
|
/// <param name="puArgErr">The index of the first argument that has an error.</param>
|
|
/// <exception cref="T:System.NotImplementedException">The method is called late-bound using the COM IDispatch interface.</exception>
|
|
// Token: 0x06001BD9 RID: 7129 RVA: 0x00069B78 File Offset: 0x00067D78
|
|
void _ParameterBuilder.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>Retrieves the attributes for this parameter.</summary>
|
|
/// <returns>Read-only. Retrieves the attributes for this parameter.</returns>
|
|
// Token: 0x170004FB RID: 1275
|
|
// (get) Token: 0x06001BDA RID: 7130 RVA: 0x00069B80 File Offset: 0x00067D80
|
|
public virtual int Attributes
|
|
{
|
|
get
|
|
{
|
|
return (int)this.attrs;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves whether this is an input parameter.</summary>
|
|
/// <returns>Read-only. Retrieves whether this is an input parameter.</returns>
|
|
// Token: 0x170004FC RID: 1276
|
|
// (get) Token: 0x06001BDB RID: 7131 RVA: 0x00069B88 File Offset: 0x00067D88
|
|
public bool IsIn
|
|
{
|
|
get
|
|
{
|
|
return (this.attrs & ParameterAttributes.In) != ParameterAttributes.None;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves whether this parameter is an output parameter.</summary>
|
|
/// <returns>Read-only. Retrieves whether this parameter is an output parameter.</returns>
|
|
// Token: 0x170004FD RID: 1277
|
|
// (get) Token: 0x06001BDC RID: 7132 RVA: 0x00069B98 File Offset: 0x00067D98
|
|
public bool IsOut
|
|
{
|
|
get
|
|
{
|
|
return (this.attrs & ParameterAttributes.Out) != ParameterAttributes.None;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves whether this parameter is optional.</summary>
|
|
/// <returns>Read-only. Specifies whether this parameter is optional.</returns>
|
|
// Token: 0x170004FE RID: 1278
|
|
// (get) Token: 0x06001BDD RID: 7133 RVA: 0x00069BA8 File Offset: 0x00067DA8
|
|
public bool IsOptional
|
|
{
|
|
get
|
|
{
|
|
return (this.attrs & ParameterAttributes.Optional) != ParameterAttributes.None;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves the name of this parameter.</summary>
|
|
/// <returns>Read-only. Retrieves the name of this parameter.</returns>
|
|
// Token: 0x170004FF RID: 1279
|
|
// (get) Token: 0x06001BDE RID: 7134 RVA: 0x00069BBC File Offset: 0x00067DBC
|
|
public virtual string Name
|
|
{
|
|
get
|
|
{
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves the signature position for this parameter.</summary>
|
|
/// <returns>Read-only. Retrieves the signature position for this parameter.</returns>
|
|
// Token: 0x17000500 RID: 1280
|
|
// (get) Token: 0x06001BDF RID: 7135 RVA: 0x00069BC4 File Offset: 0x00067DC4
|
|
public virtual int Position
|
|
{
|
|
get
|
|
{
|
|
return this.position;
|
|
}
|
|
}
|
|
|
|
/// <summary>Retrieves the token for this parameter.</summary>
|
|
/// <returns>Returns the token for this parameter.</returns>
|
|
// Token: 0x06001BE0 RID: 7136 RVA: 0x00069BCC File Offset: 0x00067DCC
|
|
public virtual ParameterToken GetToken()
|
|
{
|
|
return new ParameterToken(8 | this.table_idx);
|
|
}
|
|
|
|
/// <summary>Sets the default value of the parameter.</summary>
|
|
/// <param name="defaultValue">The default value of this parameter. </param>
|
|
/// <exception cref="T:System.ArgumentException">The parameter is not one of the supported types.-or-The type of <paramref name="defaultValue" /> does not match the type of the parameter.-or-The parameter is of type <see cref="T:System.Object" /> or other reference type, and <paramref name="defaultValue" /> is not null. </exception>
|
|
// Token: 0x06001BE1 RID: 7137 RVA: 0x00069BDC File Offset: 0x00067DDC
|
|
public virtual void SetConstant(object defaultValue)
|
|
{
|
|
this.def_value = defaultValue;
|
|
this.attrs |= ParameterAttributes.HasDefault;
|
|
}
|
|
|
|
/// <summary>Set a custom attribute using a custom attribute builder.</summary>
|
|
/// <param name="customBuilder">An instance of a helper class to define the custom attribute. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="con" /> is null. </exception>
|
|
// Token: 0x06001BE2 RID: 7138 RVA: 0x00069BF8 File Offset: 0x00067DF8
|
|
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
|
|
{
|
|
string fullName = customBuilder.Ctor.ReflectedType.FullName;
|
|
if (fullName == "System.Runtime.InteropServices.InAttribute")
|
|
{
|
|
this.attrs |= ParameterAttributes.In;
|
|
return;
|
|
}
|
|
if (fullName == "System.Runtime.InteropServices.OutAttribute")
|
|
{
|
|
this.attrs |= ParameterAttributes.Out;
|
|
return;
|
|
}
|
|
if (fullName == "System.Runtime.InteropServices.OptionalAttribute")
|
|
{
|
|
this.attrs |= ParameterAttributes.Optional;
|
|
return;
|
|
}
|
|
if (fullName == "System.Runtime.InteropServices.MarshalAsAttribute")
|
|
{
|
|
this.attrs |= ParameterAttributes.HasFieldMarshal;
|
|
this.marshal_info = CustomAttributeBuilder.get_umarshal(customBuilder, false);
|
|
return;
|
|
}
|
|
if (fullName == "System.Runtime.InteropServices.DefaultParameterValueAttribute")
|
|
{
|
|
this.SetConstant(CustomAttributeBuilder.decode_cattr(customBuilder).ctorArgs[0]);
|
|
return;
|
|
}
|
|
if (this.cattrs != null)
|
|
{
|
|
CustomAttributeBuilder[] array = new CustomAttributeBuilder[this.cattrs.Length + 1];
|
|
this.cattrs.CopyTo(array, 0);
|
|
array[this.cattrs.Length] = customBuilder;
|
|
this.cattrs = array;
|
|
}
|
|
else
|
|
{
|
|
this.cattrs = new CustomAttributeBuilder[1];
|
|
this.cattrs[0] = customBuilder;
|
|
}
|
|
}
|
|
|
|
/// <summary>Set a custom attribute using a specified custom attribute blob.</summary>
|
|
/// <param name="con">The constructor for the custom attribute. </param>
|
|
/// <param name="binaryAttribute">A byte blob representing the attributes. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="con" /> or <paramref name="binaryAttribute" /> is null. </exception>
|
|
// Token: 0x06001BE3 RID: 7139 RVA: 0x00069D20 File Offset: 0x00067F20
|
|
[ComVisible(true)]
|
|
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
|
|
{
|
|
this.SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
|
|
}
|
|
|
|
/// <summary>Specifies the marshaling for this parameter.</summary>
|
|
/// <param name="unmanagedMarshal">The marshaling information for this parameter. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="unmanagedMarshal" /> is null. </exception>
|
|
// Token: 0x06001BE4 RID: 7140 RVA: 0x00069D30 File Offset: 0x00067F30
|
|
[Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead.")]
|
|
public virtual void SetMarshal(UnmanagedMarshal unmanagedMarshal)
|
|
{
|
|
this.marshal_info = unmanagedMarshal;
|
|
this.attrs |= ParameterAttributes.HasFieldMarshal;
|
|
}
|
|
|
|
// Token: 0x04000962 RID: 2402
|
|
private MethodBase methodb;
|
|
|
|
// Token: 0x04000963 RID: 2403
|
|
private string name;
|
|
|
|
// Token: 0x04000964 RID: 2404
|
|
private CustomAttributeBuilder[] cattrs;
|
|
|
|
// Token: 0x04000965 RID: 2405
|
|
private UnmanagedMarshal marshal_info;
|
|
|
|
// Token: 0x04000966 RID: 2406
|
|
private ParameterAttributes attrs;
|
|
|
|
// Token: 0x04000967 RID: 2407
|
|
private int position;
|
|
|
|
// Token: 0x04000968 RID: 2408
|
|
private int table_idx;
|
|
|
|
// Token: 0x04000969 RID: 2409
|
|
private object def_value;
|
|
}
|
|
}
|