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


C# Class.GetExactMatchingMethod方法代码示例

本文整理汇总了C#中System.Compiler.Class.GetExactMatchingMethod方法的典型用法代码示例。如果您正苦于以下问题:C# Class.GetExactMatchingMethod方法的具体用法?C# Class.GetExactMatchingMethod怎么用?C# Class.GetExactMatchingMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Compiler.Class的用法示例。


在下文中一共展示了Class.GetExactMatchingMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindInheritedMethod

        private static Method FindInheritedMethod(Class baseClass, Method interfaceMethod)
        {
            while (baseClass != null)
            {
                if (InterfaceListContains(baseClass.Interfaces, interfaceMethod.DeclaringType))
                {
                    // instrumented in base
                    return null;
                }

                var candidate = baseClass.GetExactMatchingMethod(interfaceMethod);
                
                if (candidate != null) return candidate;
            
                baseClass = baseClass.BaseClass;
            }

            return null;
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:19,代码来源:PostExtractorChecker.cs

示例2: CheckForWrapperImplementationsForInheritedInterfaceImplementations

        private void CheckForWrapperImplementationsForInheritedInterfaceImplementations(Class Class, Interface intf)
        {
            Contract.Requires(Class != null);
            Contract.Requires(intf != null);

            var members = intf.Members;
            // if (members == null) return;
            for (int i = 0; i < members.Count; i++)
            {
                var intfMethod = members[i] as Method;
                if (intfMethod == null) continue;

                if (Class.ExplicitImplementation(intfMethod) != null) continue;

                if (Class.GetExactMatchingMethod(intfMethod) != null) continue;

                var contractMethod = HelperMethods.GetContractMethod(intfMethod);
                if (contractMethod == null) continue;

                var contract = contractMethod.Contract;
                if (contract == null) continue;
                
                if (contract.RequiresCount + contract.EnsuresCount == 0) continue;

                // find base implementing method
                var baseMethod = FindInheritedMethod(Class.BaseClass, intfMethod);
                if (baseMethod == null) continue;
                
                var baseMethodImplementsInterfaceMethod = false;
                if (baseMethod.ImplicitlyImplementedInterfaceMethods != null)
                {
                    for (int j = 0; j < baseMethod.ImplicitlyImplementedInterfaceMethods.Count; j++)
                    {
                        if (baseMethod.ImplicitlyImplementedInterfaceMethods[j] == intfMethod)
                        {
                            baseMethodImplementsInterfaceMethod = true;
                            break;
                        }
                    }
                }

                if (baseMethodImplementsInterfaceMethod) continue;

                if (this.runtimeCheckingLevel < 3 && contract.RequiresCount == 0) continue;

                if (this.addInterfaceWrappersWhenNeeded)
                {
                    AddInterfaceImplementationWrapper(Class, intfMethod, baseMethod);
                }
                else
                {
                    this.HandleError(new Warning(1080,
                        string.Format(
                            "Type {0} implements {1} by inheriting {2} causing the interface contract to not be checked at runtime. Consider adding a wrapper method.",
                            Class.FullName, intfMethod.FullName, baseMethod.FullName),
                        default(SourceContext)));
                }
            }
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:59,代码来源:PostExtractorChecker.cs


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