当前位置: 首页>>代码示例>>C#>>正文


C# MethodDefinition.IsExtensionMethod方法代码示例

本文整理汇总了C#中Mono.Cecil.MethodDefinition.IsExtensionMethod方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.IsExtensionMethod方法的具体用法?C# MethodDefinition.IsExtensionMethod怎么用?C# MethodDefinition.IsExtensionMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.IsExtensionMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMethodClassification

 /// <summary>
 /// Gets the method classification for this method.
 /// </summary>
 /// <param name="method">The method definition.</param>
 /// <returns>A method classification.</returns>
 public static MethodClassification GetMethodClassification(MethodDefinition method)
 {
     if (method.IsConstructor)
     {
         return MethodClassification.Constructor;
     }
     if (method.IsSpecialName)
     {
         if (method.IsOperator())
         {
             return MethodClassification.Operator;
         }
         if (method.Name.StartsWith("add_"))
         {
             return MethodClassification.EventAccessor;
         }
         if (method.Name.StartsWith("remove_"))
         {
             return MethodClassification.EventAccessor;
         }
     }
     if (method.IsExtensionMethod())
     {
         return MethodClassification.ExtensionMethod;
     }
     return MethodClassification.Method;
 }
开发者ID:reicheltp,项目名称:website,代码行数:32,代码来源:MethodClassifier.cs

示例2: GetCodeMemberMethod

 private CodeTypeMember GetCodeMemberMethod(MethodDefinition methodDefinition) {
     CodeMemberMethod codeMemberMethod;
     if(!methodDefinition.IsConstructor) {
         codeMemberMethod = new CodeMemberMethod() { Name = GetMemberMethodName(methodDefinition) };
     }
     else {
         codeMemberMethod = new CodeConstructor();
     }
     codeMemberMethod.Attributes = GetMemberAttributes(methodDefinition);
     FillCustomAttribute(codeMemberMethod.CustomAttributes, methodDefinition.CustomAttributes);
     FillGenericParameters(codeMemberMethod.TypeParameters, methodDefinition.GenericParameters);
     codeMemberMethod.ReturnType = new CodeTypeReference(GetTypeReferenceName(methodDefinition.ReturnType));
     bool isExtensionMethod = methodDefinition.IsExtensionMethod();
     List<ParameterDefinition> outParameters = new List<ParameterDefinition>();
     foreach(var parameter in methodDefinition.Parameters) {
         CodeParameterDeclarationExpression p = GetParameterExpression(parameter, isExtensionMethod && parameter == methodDefinition.Parameters.First());
         if(parameter.IsOut) {
             outParameters.Add(parameter);
         }
         codeMemberMethod.Parameters.Add(p);
     }
     if(methodDefinition.HasBody || !methodDefinition.IsAbstract) {
         if(methodDefinition.IsConstructor && methodDefinition.DeclaringType.IsValueType) {
             foreach(var fieldDefinition in methodDefinition.DeclaringType.Fields.Where(i => !i.IsStatic && IsEnableField(i))) {
                 CodeAssignStatement assign = new CodeAssignStatement(
                     new CodeArgumentReferenceExpression("this." + fieldDefinition.Name),
                     GetDefalutValue(fieldDefinition.FieldType));
                 codeMemberMethod.Statements.Add(assign);
             }
         }
         foreach(var outParameter in outParameters) {
             CodeAssignStatement assign = new CodeAssignStatement(
                 new CodeArgumentReferenceExpression(outParameter.Name),
                 GetDefalutValue(outParameter.ParameterType));
             codeMemberMethod.Statements.Add(assign);
         }
         if(methodDefinition.ReturnType.MetadataType != MetadataType.Void) {
             codeMemberMethod.Statements.Add(new CodeMethodReturnStatement(GetDefalutValue(methodDefinition.ReturnType)));
         }
     }
     if(methodDefinition.IsOpImplicit()) {
         string code = codeMemberMethod.GenCode();
         Utility.FixOpImplicit(ref code);
         return new CodeSnippetTypeMember(code);
     }
     else if(methodDefinition.IsOpExplicit()) {
         string code = codeMemberMethod.GenCode();
         Utility.FixOpExplicit(ref code);
         return new CodeSnippetTypeMember(code);
     }
     return codeMemberMethod;
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:52,代码来源:Wrap.cs


注:本文中的Mono.Cecil.MethodDefinition.IsExtensionMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。