當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。