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