本文整理汇总了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;
}