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


C# TypeNode.FindShadow方法代码示例

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


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

示例1: SkipThisTypeDueToMismatchInReferenceAssemblyPlatform

        private bool SkipThisTypeDueToMismatchInReferenceAssemblyPlatform(AssemblyNode ultimateTargetAssembly,
            TypeNode typeNode)
        {
            if (ultimateTargetAssembly == null) return false;

            if (typeNode == this.contractNodes.ContractClass)
                return false; // don't skip contract methods as we need to extract their contracts

            if (HelperMethods.IsCompilerGenerated(typeNode)) return false; // don't skip closures etc.
            var typeWithSeparateContractClass = HelperMethods.IsContractTypeForSomeOtherTypeUnspecialized(typeNode, this.contractNodes);

            if (typeWithSeparateContractClass != null)
            {
                typeNode = typeWithSeparateContractClass; // see if this one is skipped
            }

            // now see if we have corresponding target type
            if (typeNode.FindShadow(ultimateTargetAssembly) != null) return false; // have target

            return true; // skip it.
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:21,代码来源:ExtractorVisitor.cs

示例2: GetImplementation

        /// <summary>
        /// Returns the method implemented or overridden by the contractClass corresponding to the abstract method.
        ///
        /// Can't use TypeNode.GetImplementingMethod because the Reader creates the names of explicit
        /// interface methods such that it doesn't return them: it returns only implicit interface
        /// implementations. A contract class should never have both implicit and explicit
        /// implementations, so this just looks for an implicit first, then an explicit if that fails.
        /// </summary>
        /// <param name="contractClass">A class holding the contracts for an interface.</param>
        /// <param name="interfaceMethod">A method from that interface.</param>
        /// <returns>The method in the class that implements the interface method.  </returns>
        internal static Method GetImplementation(TypeNode contractClass, Method abstractMethod)
        {
            Method m = contractClass.FindShadow(abstractMethod);
            
            if (m != null) // implicit implementation
                return m;

            if (abstractMethod.DeclaringType is Interface)
            {
                foreach (Member mem in contractClass.Members)
                {
                    m = mem as Method;
                    if (m == null || m.ImplementedInterfaceMethods == null) continue;

                    foreach (Method ifaceMethod in m.ImplementedInterfaceMethods)
                    {
                        if (ifaceMethod == null) continue;

                        if (ifaceMethod == abstractMethod || ifaceMethod.Template == abstractMethod)
                            return m; // explicit implementation
                        
                        if (ifaceMethod.Template != null && ifaceMethod.Template == abstractMethod.Template)
                        {
                            return m;
                        }
                    }
                }
            }

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

示例3: VisitTypeNode

        public override void VisitTypeNode(TypeNode typeNode)
        {
            if (typeNode == null) return;

            // we might have copied this type already
            if (this.duplicatedMembers[typeNode.UniqueKey] != null)
            {
                return;
            }

            TypeNode targetType = typeNode.FindShadow(this.targetAssembly);
            if (targetType != null)
            {
                if (targetType.Contract == null)
                {
                    targetType.Contract = new TypeContract(targetType, true);
                }

                this.outOfBandDuplicator.TargetType = targetType;
                if (typeNode.Contract != null)
                {
                    InvariantList duplicatedInvariants =
                        this.outOfBandDuplicator.VisitInvariantList(typeNode.Contract.Invariants);

                    targetType.Contract.Invariants = duplicatedInvariants;
                }

                CopyAttributesWithoutDuplicateUnlessAllowMultiple(targetType, typeNode);

                base.VisitTypeNode(typeNode);
            }
            else
            {
                // target type does not exist. Copy it
                if (typeNode.DeclaringType != null)
                {
                    // nested types are members and have been handled by CopyMissingMembers
                }
                else
                {
                    this.outOfBandDuplicator.VisitTypeNode(typeNode);
                }
            }
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:44,代码来源:CopyOutOfBandContracts.cs


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