本文整理汇总了C#中Mono.Cecil.MethodReference类的典型用法代码示例。如果您正苦于以下问题:C# MethodReference类的具体用法?C# MethodReference怎么用?C# MethodReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodReference类属于Mono.Cecil命名空间,在下文中一共展示了MethodReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CloneMethodWithDeclaringType
private static MethodReference CloneMethodWithDeclaringType(MethodDefinition methodDef, TypeReference declaringTypeRef)
{
if (!declaringTypeRef.IsGenericInstance || methodDef == null)
{
return methodDef;
}
var methodRef = new MethodReference(methodDef.Name, methodDef.ReturnType, declaringTypeRef)
{
CallingConvention = methodDef.CallingConvention,
HasThis = methodDef.HasThis,
ExplicitThis = methodDef.ExplicitThis
};
foreach (var paramDef in methodDef.Parameters)
{
methodRef.Parameters.Add(new ParameterDefinition(paramDef.Name, paramDef.Attributes, paramDef.ParameterType));
}
foreach (var genParamDef in methodDef.GenericParameters)
{
methodRef.GenericParameters.Add(new GenericParameter(genParamDef.Name, methodRef));
}
return methodRef;
}
开发者ID:mdabbagh88,项目名称:Ionad,代码行数:26,代码来源:CecilExtensions.cs
示例2: Convert
public IEnumerable<Instruction> Convert(MethodReference method)
{
if (method.Name != "IndexOf")
{
yield break;
}
if (method.Parameters.Matches("String"))
{
yield return Instruction.Create(OpCodes.Ldc_I4, StringComparisonConstant);
yield return Instruction.Create(OpCodes.Callvirt, reference_String);
yield break;
}
if (method.Parameters.Matches("String","Int32"))
{
yield return Instruction.Create(OpCodes.Ldc_I4, StringComparisonConstant);
yield return Instruction.Create(OpCodes.Callvirt, reference_StringInt);
yield break;
}
if (method.Parameters.Matches("String", "Int32", "Int32"))
{
yield return Instruction.Create(OpCodes.Ldc_I4, StringComparisonConstant);
yield return Instruction.Create(OpCodes.Callvirt, reference_StringIntInt);
}
}
开发者ID:mdabbagh88,项目名称:Caseless,代码行数:25,代码来源:IndexOfConverter.cs
示例3: FunctionPointerType
public FunctionPointerType()
: base(null)
{
this.function = new MethodReference ();
this.function.Name = "method";
this.etype = MD.ElementType.FnPtr;
}
开发者ID:Tianjiao,项目名称:cecil,代码行数:7,代码来源:FunctionPointerType.cs
示例4: add
public void add(MethodReference calledMethod)
{
int count;
var key = new MethodReferenceAndDeclaringTypeKey(calledMethod);
calls.TryGetValue(key, out count);
calls[key] = count + 1;
}
开发者ID:n017,项目名称:NETDeob,代码行数:7,代码来源:DotNetUtils.cs
示例5: BuildMethodParameterList
internal static string BuildMethodParameterList(MethodReference interopMethod, MethodReference interfaceMethod, Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver, MarshalType marshalType, bool includeTypeNames)
{
List<string> elements = new List<string>();
int num = 0;
foreach (ParameterDefinition definition in interopMethod.Parameters)
{
MarshalInfo marshalInfo = interfaceMethod.Parameters[num].MarshalInfo;
DefaultMarshalInfoWriter writer = MarshalDataCollector.MarshalInfoWriterFor(typeResolver.Resolve(definition.ParameterType), marshalType, marshalInfo, true, false, false, null);
foreach (MarshaledType type in writer.MarshaledTypes)
{
elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0} {1}", type.DecoratedName, Naming.ForParameterName(definition) + type.VariableName));
}
num++;
}
TypeReference reference2 = typeResolver.Resolve(interopMethod.ReturnType);
if (reference2.MetadataType != MetadataType.Void)
{
MarshalInfo info2 = interfaceMethod.MethodReturnType.MarshalInfo;
MarshaledType[] marshaledTypes = MarshalDataCollector.MarshalInfoWriterFor(reference2, marshalType, info2, true, false, false, null).MarshaledTypes;
for (int i = 0; i < (marshaledTypes.Length - 1); i++)
{
elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[i].DecoratedName, Naming.ForComInterfaceReturnParameterName() + marshaledTypes[i].VariableName));
}
elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[marshaledTypes.Length - 1].DecoratedName, Naming.ForComInterfaceReturnParameterName()));
}
return EnumerableExtensions.AggregateWithComma(elements);
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:27,代码来源:ComInterfaceWriter.cs
示例6: MakeHostInstanceGeneric
public static MethodReference MakeHostInstanceGeneric(this MethodReference @this, params TypeReference[] genericArguments)
{
var genericDeclaringType = new GenericInstanceType(@this.DeclaringType);
foreach (var genericArgument in genericArguments)
{
genericDeclaringType.GenericArguments.Add(genericArgument);
}
var reference = new MethodReference(@this.Name, @this.ReturnType, genericDeclaringType)
{
HasThis = @this.HasThis,
ExplicitThis = @this.ExplicitThis,
CallingConvention = @this.CallingConvention
};
foreach (var parameter in @this.Parameters)
{
reference.Parameters.Add(new ParameterDefinition(parameter.ParameterType));
}
foreach (var genericParam in @this.GenericParameters)
{
reference.GenericParameters.Add(new GenericParameter(genericParam.Name, reference));
}
return reference;
}
开发者ID:realm,项目名称:realm-dotnet,代码行数:27,代码来源:MethodReferenceExtensions.cs
示例7: FixArguments
private void FixArguments(MethodReference method, ExpressionCollection arguments)
{
TypeDefinition declaringTypeDefinition = method.DeclaringType.Resolve();
if (declaringTypeDefinition == null)
{
return;
}
List<MethodDefinition> sameNameMethods = GetSameNameMethods(declaringTypeDefinition, method, arguments);
if (sameNameMethods.Count > 0)
{
for (int i = 0; i < arguments.Count; i++)
{
TypeReference paramType = method.Parameters[i].ResolveParameterType(method);
if (!arguments[i].HasType)
{
continue;
}
if (arguments[i].ExpressionType.FullName == paramType.FullName)
{
continue;
}
if (ShouldAddCast(arguments[i], sameNameMethods, i, paramType))
{
arguments[i] = new CastExpression(arguments[i], paramType, null);
}
}
}
}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:28,代码来源:FixMethodOverloadsStep.cs
示例8: CastMethodArguments
private void CastMethodArguments(MethodReference method, ExpressionCollection arguments)
{
for (int i = 0; i < arguments.Count; i++)
{
Expression argument = arguments[i];
TypeReference parameterType = method.Parameters[i].ResolveParameterType(method);
if (argument.HasType && parameterType != null && !(argument is LiteralExpression))
{
TypeReference argumentType = argument.ExpressionType;
if ((IsUnsignedIntegerType(argumentType) && IsSignedIntegerType(parameterType)) || (IsSignedIntegerType(argumentType) && IsUnsignedIntegerType(parameterType)))
{
Expression toCast = argument;
if (argument is CastExpression)
{
CastExpression argumentCast = argument as CastExpression;
if (IsIntegerType(argumentCast.TargetType))
{
toCast = argumentCast.Expression;
}
}
arguments[i] = new CastExpression(toCast, parameterType, null);
}
}
}
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:29,代码来源:CastIntegersStep.cs
示例9: AreSame
public static bool AreSame(this MethodReference method, MethodReference other)
{
var possiblyEqual =
method.DeclaringType.FullName.Equals(other.DeclaringType.FullName, StringComparison.Ordinal)
&& method.FullName.Equals(other.FullName, StringComparison.Ordinal)
&& method.Parameters.Count == other.Parameters.Count
&& method.GenericParameters.Count == other.GenericParameters.Count
&& method.IsGenericInstance == other.IsGenericInstance;
if (!possiblyEqual)
{
return false;
}
for (var i = 0; i < method.Parameters.Count; ++i)
{
var pThis = method.Parameters[i];
var pThat = other.Parameters[i];
if (!pThis.ParameterType.FullName.Equals(pThat.ParameterType.FullName, StringComparison.Ordinal))
{
return false;
}
}
return true;
}
开发者ID:benjamin-bader,项目名称:stiletto,代码行数:27,代码来源:MethodReferenceExtensions.cs
示例10: GetNormalOperand
public MethodReference GetNormalOperand(MethodReference methodReference)
{
var name = methodReference.Name;
if (name == "Trace")
{
return TraceMethod;
}
if (name == "Debug")
{
return DebugMethod;
}
if (name == "Info")
{
return InfoMethod;
}
if (name == "Warn")
{
return WarnMethod;
}
if (name == "Error")
{
return ErrorMethod;
}
if (name == "Fatal")
{
return FatalMethod;
}
throw new Exception("Invalid method name");
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:29,代码来源:InjectorExtentions.cs
示例11: Create
public static GenericBindingContext Create(MethodReference methodReference)
{
var genericMethod = methodReference as GenericInstanceMethod;
return genericMethod != null
? new GenericBindingContext(genericMethod)
: new GenericBindingContext();
}
开发者ID:gmf520,项目名称:Smocks,代码行数:7,代码来源:GenericBindingContext.cs
示例12: InjectEqualsObject
public static MethodDefinition InjectEqualsObject(TypeDefinition type, TypeReference typeRef, MethodReference newEquals, int typeCheck)
{
var methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual;
var method = new MethodDefinition("Equals", methodAttributes, ReferenceFinder.Boolean.TypeReference);
method.CustomAttributes.MarkAsGeneratedCode();
var obj = method.Parameters.Add("obj", ReferenceFinder.Object.TypeReference);
var body = method.Body;
var result = body.Variables.Add("result", ReferenceFinder.Boolean.TypeReference);
var ins = body.Instructions;
var labelRet = Instruction.Create(OpCodes.Nop);
AddCheckEqualsReference(type, ins);
ins.If(
c => AddTypeChecking(type, typeRef, typeCheck, c),
t => AddInternalEqualsCall(type, typeRef, newEquals, t, result),
e => AddReturnFalse(e));
AddReturn(ins, labelRet, result);
body.OptimizeMacros();
type.Methods.Add(method);
return method;
}
开发者ID:kzaikin,项目名称:Equals,代码行数:30,代码来源:EqualsInjector.cs
示例13: GetMethod
public static MethodDefinition GetMethod(IList<MethodDefinition> methods, MethodReference reference)
{
for (int i = 0; i < methods.Count; i++) {
var method = methods [i];
if (method.Name != reference.Name)
continue;
if (!AreSame (method.ReturnType, reference.ReturnType))
continue;
if (method.HasParameters != reference.HasParameters)
continue;
if (!method.HasParameters && !reference.HasParameters)
return method;
if (!AreSame (method.Parameters, reference.Parameters))
continue;
return method;
}
return null;
}
开发者ID:peterwald,项目名称:cecil,代码行数:25,代码来源:MetadataResolver.cs
示例14: ILBlockTranslator
public ILBlockTranslator(AssemblyTranslator translator, DecompilerContext context, MethodReference methodReference, MethodDefinition methodDefinition, ILBlock ilb, IEnumerable<ILVariable> parameters, IEnumerable<ILVariable> allVariables)
{
Translator = translator;
Context = context;
ThisMethodReference = methodReference;
ThisMethod = methodDefinition;
Block = ilb;
SpecialIdentifiers = new JSIL.SpecialIdentifiers(TypeSystem);
if (methodReference.HasThis)
Variables.Add("this", JSThisParameter.New(methodReference.DeclaringType, methodReference));
foreach (var parameter in parameters) {
if ((parameter.Name == "this") && (parameter.OriginalParameter.Index == -1))
continue;
ParameterNames.Add(parameter.Name);
Variables.Add(parameter.Name, new JSParameter(parameter.Name, parameter.Type, methodReference));
}
foreach (var variable in allVariables) {
var v = JSVariable.New(variable, methodReference);
if (Variables.ContainsKey(v.Identifier)) {
v = new JSVariable(variable.OriginalVariable.Name, variable.Type, methodReference);
RenamedVariables[variable] = v;
Variables.Add(v.Identifier, v);
} else {
Variables.Add(v.Identifier, v);
}
}
}
开发者ID:aprishchepov,项目名称:JSIL,代码行数:32,代码来源:ILBlockTranslator.cs
示例15: GetExternalMethod
public MethodDefinition GetExternalMethod (MethodReference mr) {
string library = GetSymbolLibrary (mr.Name);
if (library != null) {
List<MethodDefinition> methods = null;
if (externalMethods.ContainsKey (mr.Name)) {
methods = externalMethods [mr.Name];
foreach (MethodDefinition method in methods) {
if (CompareMethodSignatures (mr, method)) {
return method;
}
}
} else {
methods = new List<MethodDefinition> ();
externalMethods [mr.Name] = methods;
}
if (! referredLibraries.ContainsKey (library)) {
referredLibraries [library] = new ModuleReference (library);
}
MethodDefinition md = CreateExternalMethod (mr, library, referredLibraries [library]);
methods.Add (md);
return md;
} else {
return null;
}
}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:26,代码来源:NativeLibraryHandler.cs
示例16: GetLevelForLog
public OpCode GetLevelForLog(MethodReference methodReference)
{
var name = methodReference.Name;
if (name == "Debug" || name == "DebugException")
{
return OpCodes.Ldc_I4_2;
}
if (name == "Info" || name == "InfoException")
{
return OpCodes.Ldc_I4_3;
}
if (name == "Warn" || name == "WarnException")
{
return OpCodes.Ldc_I4_4;
}
if (name == "Error" || name == "ErrorException")
{
return OpCodes.Ldc_I4_5;
}
if (name == "Fatal" || name == "FatalException")
{
return OpCodes.Ldc_I4_6;
}
throw new Exception("Invalid method name");
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:25,代码来源:InjectorExtentions.cs
示例17: GetExceptionOperand
public MethodReference GetExceptionOperand(MethodReference methodReference)
{
var name = methodReference.Name;
if (name == "DebugException")
{
return DebugExceptionMethod;
}
if (name == "InfoException")
{
return InfoExceptionMethod;
}
if (name == "WarnException")
{
return WarnExceptionMethod;
}
if (name == "ErrorException")
{
return ErrorExceptionMethod;
}
if (name == "FatalException")
{
return FatalExceptionMethod;
}
throw new Exception("Invalid method name");
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:25,代码来源:InjectorExtentions.cs
示例18: MethodSignaturesMatchIgnoreStaticness
internal static bool MethodSignaturesMatchIgnoreStaticness(MethodReference candidate, MethodReference method)
{
if (candidate.Parameters.Count != method.Parameters.Count)
{
return false;
}
if (candidate.GenericParameters.Count != method.GenericParameters.Count)
{
return false;
}
Unity.IL2CPP.ILPreProcessor.TypeResolver resolver = new Unity.IL2CPP.ILPreProcessor.TypeResolver(candidate.DeclaringType as GenericInstanceType, candidate as GenericInstanceMethod);
Unity.IL2CPP.ILPreProcessor.TypeResolver resolver2 = new Unity.IL2CPP.ILPreProcessor.TypeResolver(method.DeclaringType as GenericInstanceType, method as GenericInstanceMethod);
if (!Unity.IL2CPP.Common.TypeReferenceEqualityComparer.AreEqual(resolver.ResolveReturnType(candidate), resolver2.ResolveReturnType(method), TypeComparisonMode.SignatureOnly))
{
return false;
}
for (int i = 0; i < candidate.Parameters.Count; i++)
{
if (!Unity.IL2CPP.Common.TypeReferenceEqualityComparer.AreEqual(resolver.ResolveParameterType(candidate, candidate.Parameters[i]), resolver2.ResolveParameterType(method, method.Parameters[i]), TypeComparisonMode.SignatureOnly))
{
return false;
}
}
return true;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:VirtualMethodResolution.cs
示例19: GetLevel
public OpCode GetLevel(MethodReference methodReference)
{
var name = methodReference.Name;
if (name == "get_IsDebugEnabled")
{
return OpCodes.Ldc_I4_2;
}
if (name == "get_IsInfoEnabled")
{
return OpCodes.Ldc_I4_3;
}
if (name == "get_IsWarnEnabled")
{
return OpCodes.Ldc_I4_4;
}
if (name == "get_IsErrorEnabled")
{
return OpCodes.Ldc_I4_5;
}
if (name == "get_IsFatalEnabled")
{
return OpCodes.Ldc_I4_6;
}
throw new Exception("Invalid method name");
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:25,代码来源:InjectorExtentions.cs
示例20: GetFormatOperand
public MethodReference GetFormatOperand(MethodReference methodReference)
{
var name = methodReference.Name;
if (name == "Debug")
{
return DebugFormatMethod;
}
if (name == "Info")
{
return InfoFormatMethod;
}
if (name == "Warn")
{
return WarnFormatMethod;
}
if (name == "Error")
{
return ErrorFormatMethod;
}
if (name == "Fatal")
{
return FatalFormatMethod;
}
throw new Exception("Invalid method name");
}
开发者ID:Fody,项目名称:Anotar,代码行数:25,代码来源:InjectorExtensions.cs
注:本文中的Mono.Cecil.MethodReference类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论