当前位置: 首页>>代码示例>>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;未经允许,请勿转载。