本文整理汇总了C#中IMethod.GetMethodDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IMethod.GetMethodDefinition方法的具体用法?C# IMethod.GetMethodDefinition怎么用?C# IMethod.GetMethodDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethod
的用法示例。
在下文中一共展示了IMethod.GetMethodDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
/// <summary>
/// </summary>
/// <param name="method">
/// </param>
/// <param name="allowToUseDefinitionAsSpecialization">
/// </param>
private void Init(IMethod method, bool allowToUseDefinitionAsSpecialization = false)
{
if (method.IsGenericMethodDefinition)
{
this.MethodDefinition = method;
if (allowToUseDefinitionAsSpecialization)
{
this.MethodSpecialization = method;
}
}
if (method.IsGenericMethod)
{
this.MethodSpecialization = method;
if (this.MethodDefinition == null)
{
this.MethodDefinition = method.GetMethodDefinition();
}
}
}
示例2: CreateWrapperMethod
private MethodDefDeclaration CreateWrapperMethod( IMethod loggerMethod )
{
MethodDefDeclaration wrapperMethod = new MethodDefDeclaration
{
Name = this.implementationType.Methods.GetUniqueName( loggerMethod.Name + "{0}" ),
Attributes = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig,
};
this.implementationType.Methods.Add( wrapperMethod );
wrapperMethod.ReturnParameter = new ParameterDeclaration
{
Attributes = ParameterAttributes.Retval,
ParameterType = this.module.Cache.GetIntrinsic( IntrinsicType.Void )
};
ITypeSignature loggerFieldType = loggerMethod.DeclaringType.GetNakedType();
MethodDefDeclaration loggerMethodDefinition = loggerMethod.GetMethodDefinition();
if ( !loggerMethodDefinition.IsStatic )
{
wrapperMethod.Parameters.Add( new ParameterDeclaration( 0, "logger", loggerFieldType ) );
}
for ( int i = 0; i < loggerMethodDefinition.Parameters.Count; i++ )
{
ParameterDeclaration parameter = loggerMethodDefinition.Parameters[i];
wrapperMethod.Parameters.Add( new ParameterDeclaration( wrapperMethod.Parameters.Count, parameter.Name,
parameter.ParameterType.TranslateType( this.module ) ) );
}
this.EmitWrapperCallBody( wrapperMethod, loggerMethod );
return wrapperMethod;
}