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


C# TypeDefinition.TryGetMethod方法代码示例

本文整理汇总了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;
        }
开发者ID:JesseBuesking,项目名称:BB.DeepCopy,代码行数:18,代码来源:ModuleWeaver.cs

示例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;
        }
开发者ID:JesseBuesking,项目名称:BB.DeepCopy,代码行数:15,代码来源:ModuleWeaver.cs

示例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);
        }
开发者ID:JesseBuesking,项目名称:BB.DeepCopy,代码行数:36,代码来源:ModuleWeaver.cs


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