當前位置: 首頁>>代碼示例>>C#>>正文


C# MethodDefinition.IsOpExplicit方法代碼示例

本文整理匯總了C#中Mono.Cecil.MethodDefinition.IsOpExplicit方法的典型用法代碼示例。如果您正苦於以下問題:C# MethodDefinition.IsOpExplicit方法的具體用法?C# MethodDefinition.IsOpExplicit怎麽用?C# MethodDefinition.IsOpExplicit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.IsOpExplicit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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.IsOpExplicit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。