本文整理汇总了C#中Mono.Cecil.TypeDefinition.TryGetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.TryGetMethod方法的具体用法?C# TypeDefinition.TryGetMethod怎么用?C# TypeDefinition.TryGetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.TryGetMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleReturnType
private void HandleReturnType(bool baseIsAbstractClass, TypeDefinition baseDefinition,
MethodDefinition deepCopyMethod)
{
// Use the return type defined on the base method we're overriding (if applicable).
if (!baseIsAbstractClass)
return;
// if (baseDefinition.TryGetMethod(this._deepCopyMethodName, out interCopy))
// {
// if (interCopy.IsVirtual)
// deepCopyMethod.Overrides.Add(interCopy);
// }
// Update the return type to match the one that we're supposed to override.
MethodDefinition baseTypeDeepCopyMethod;
if (baseDefinition.TryGetMethod(this._deepCopyMethodName, out baseTypeDeepCopyMethod))
deepCopyMethod.ReturnType = baseTypeDeepCopyMethod.ReturnType;
}
示例2: HandlePotentialAbstractOverride
private void HandlePotentialAbstractOverride(bool baseIsAbstractClass, TypeDefinition baseDefinition,
ref MethodAttributes methodAttributes)
{
if (!baseIsAbstractClass)
return;
// Get the deep copy method on the base type.
MethodDefinition baseTypeDeepCopyMethod;
if (!baseDefinition.TryGetMethod(this._deepCopyMethodName, out baseTypeDeepCopyMethod))
return;
// Is the deep copy method on the base type marked as 'override'?
if (baseTypeDeepCopyMethod.IsVirtual)
methodAttributes |= MethodAttributes.Virtual;
}
示例3: SafeCallDeepCopy
private void SafeCallDeepCopy(
Collection<VariableDefinition> variables,
Collection<ExceptionHandler> exceptionHandlers,
Collection<Instruction> instructions,
TypeDefinition typeDefinition,
Action<Collection<Instruction>> load,
Action<Collection<Instruction>> store)
{
MethodDefinition deepCopy;
if (!typeDefinition.TryGetMethod(this._deepCopyMethodName, out deepCopy))
throw new Exception(
String.Format("Sub-type {0} does not implement DeepCopy.", typeDefinition.FullName));
var var0 = variables.AddV(typeDefinition);
// Load the object, and check to see if it's null.
instructions.AddI(OpCodes.Nop);
instructions.AddI(OpCodes.Ldarg_0);
load(instructions);
instructions.AddI(OpCodes.Stloc, var0);
instructions.AddI(OpCodes.Ldloc_0);
instructions.AddI(OpCodes.Ldloc, var0);
var loadNull = Instruction.Create(OpCodes.Ldnull);
instructions.AddI(OpCodes.Brfalse_S, loadNull);
instructions.AddI(OpCodes.Ldloc, var0);
instructions.AddI(OpCodes.Callvirt, deepCopy);
var noOp = Instruction.Create(OpCodes.Nop);
instructions.AddI(OpCodes.Br_S, noOp);
instructions.Add(loadNull);
instructions.Add(noOp);
store(instructions);
}