當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeReference.GetFriendlyFullName方法代碼示例

本文整理匯總了C#中Mono.Cecil.TypeReference.GetFriendlyFullName方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeReference.GetFriendlyFullName方法的具體用法?C# TypeReference.GetFriendlyFullName怎麽用?C# TypeReference.GetFriendlyFullName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.TypeReference的用法示例。


在下文中一共展示了TypeReference.GetFriendlyFullName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AreEqual

        public static bool AreEqual(TypeReference firstType, TypeReference secondType)
        {
            if (firstType.GetFriendlyFullName(null) == secondType.GetFriendlyFullName(null))
            {
                return true;
            }

            TypeReference firstTypeRef = firstType.GetElementType();
            TypeReference secondTypeRef = secondType.GetElementType();
            if (firstTypeRef.HasGenericParameters && secondTypeRef.HasGenericParameters)
            {
                if (firstTypeRef.FullName == secondTypeRef.FullName &&
                    firstTypeRef.GenericParameters.Count == secondTypeRef.GenericParameters.Count)
                {
                    return true;
                }
            }

            return false;
        }
開發者ID:Feng2012,項目名稱:JustDecompileEngine,代碼行數:20,代碼來源:TypeNamesComparer.cs

示例2: IsSubtype

        /// <summary>
        /// Checks if <paramref name="supposedSubType"/> is subtype of <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The supposed parent type.</param>
        /// <param name="supposedSubType">The supposed inheriting type.</param>
        /// <returns>Returns True if <paramref name="supposedSubType"/> is subtype of <paramref name="type"/>.</returns>
        private bool IsSubtype(TypeReference type, TypeReference supposedSubType)
        {
            type = RemoveModifiers(type);
            supposedSubType = RemoveModifiers(supposedSubType);

            if (supposedSubType.GetFriendlyFullName(null) == type.GetFriendlyFullName(null) || type.FullName == "System.Object")
            {
                ///The types are the same, or the check is if a type inherits Object
                return true;
            }
            if (IsArrayAssignable(type, supposedSubType))
            {
                return true;
            }
            TypeDefinition supposedSubTypeDef = supposedSubType.Resolve();
            if (supposedSubTypeDef == null)
            {
                //happens with generics only;
                return true;
            }
            if (type is GenericInstanceType)
            {
                type = type.GetElementType();
            }
            while (supposedSubTypeDef != null)
            {
                if (type.GetFriendlyFullName(null) == supposedSubTypeDef.GetFriendlyFullName(null))
                {
                    ///Must be here, since mono fails on resolving types sometimes.
                    return true;
                }
                foreach (TypeReference @interface in supposedSubTypeDef.Interfaces)
                {
                    if (@interface.Name == type.Name)
                    {
                        return true;
                    }
                }

                if (supposedSubTypeDef.BaseType == null)
                {
                    ///We are at the root of the class hierarcy, and no match was made.
                    return false;
                }
                supposedSubTypeDef = supposedSubTypeDef.BaseType.Resolve();
            }
            return false;
        }
開發者ID:saravanaram,項目名稱:JustDecompileEngine,代碼行數:54,代碼來源:TypeInferer.cs

示例3: WriteType

        protected void WriteType(TypeReference type, ILNameSyntax syntax)
        {
            if (type is ArrayType)
            {
                WriteArrayType(type, syntax);
                return;
            }
            string name = ILHelpers.PrimitiveTypeName(type.GetFriendlyFullName(Language));
            if (syntax == ILNameSyntax.ShortTypeName)
            {
                if (name != null)
                    WriteReference(name, type);
                else
                    WriteReference(ILHelpers.Escape(type.Name), type);
            }
            else if ((syntax == ILNameSyntax.Signature || syntax == ILNameSyntax.SignatureNoNamedTypeParameters) && name != null)
            {
                WriteReference(name, type);
            }
            else
            {
                if (syntax == ILNameSyntax.Signature || syntax == ILNameSyntax.SignatureNoNamedTypeParameters)
                    WriteKeyWordPostSpace(type.IsValueType ? "valuetype" : "class");

                if (type.DeclaringType != null)
                {
                    WriteTypeReference(type.DeclaringType, ILNameSyntax.TypeName);
                    WriteKeyword("/");
                    WriteReference(ILHelpers.Escape(type.Name), type);
                }
                else
                {
                    if (!type.IsDefinition && type.Scope != null && !(type is TypeSpecification))
                    {
                        WriteToken("[");
                        WriteEscaped(type.Scope.Name);
                        WriteToken("]");
                    }
                    WriteReference(ILHelpers.Escape(type.FullName), type);
                }
            }
        }
開發者ID:juancarlosbaezpozos,項目名稱:JustDecompileEngine,代碼行數:42,代碼來源:IntermediateLanguageWriter.cs


注:本文中的Mono.Cecil.TypeReference.GetFriendlyFullName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。