• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MetadataTypeName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MetadataTypeName的典型用法代码示例。如果您正苦于以下问题:C# MetadataTypeName类的具体用法?C# MetadataTypeName怎么用?C# MetadataTypeName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetadataTypeName类属于命名空间,在下文中一共展示了MetadataTypeName类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LookupTopLevelMetadataTypeInCache

        private NamedTypeSymbol LookupTopLevelMetadataTypeInCache(ref MetadataTypeName emittedName)
        {
            NamedTypeSymbol result = null;
            if (this.emittedNameToTypeMap.TryGetValue(emittedName.ToKey(), out result))
            {
                return result;
            }

            return null;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:NonMissingAssemblySymbol.cs


示例2: GetAssemblyForForwardedType

 /// <summary>
 /// If this module forwards the given type to another assembly, return that assembly;
 /// otherwise, return null.
 /// </summary>
 /// <param name="fullName">Type to look up.</param>
 /// <returns>Assembly symbol or null.</returns>
 /// <remarks>
 /// The returned assembly may also forward the type.
 /// </remarks>
 internal AssemblySymbol GetAssemblyForForwardedType(ref MetadataTypeName fullName)
 {
     string matchedName;
     AssemblyReferenceHandle assemblyRef = Module.GetAssemblyForForwardedType(fullName.FullName, ignoreCase: false, matchedName: out matchedName);
     return assemblyRef.IsNil ? null : this.GetReferencedAssemblySymbol(assemblyRef);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:15,代码来源:PEModuleSymbol.cs


示例3: FindType

        public MetadataType FindType(MetadataTypeName typeName)
        {
            if (typeName == null)
                return null;

            var foundType = AllTypes
                .FirstOrDefault(x => (typeName.Namespace == null || x.Namespace == typeName.Namespace)
                    && x.Name == typeName.Name
                    && x.GenericArgs.Safe().Count() == typeName.GenericArgs.Safe().Count());

            if (foundType != null)
                return foundType;

            if (typeName.Name == typeof(QueryBase).Name || typeName.Name == typeof(QueryBase<>).Name)
                return CreateType(typeof(QueryBase)); //Properties are on QueryBase


            if (typeName.Name == typeof(AuthUserSession).Name)
                return CreateType(typeof(AuthUserSession));

            return null;
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:22,代码来源:SwiftGenerator.cs


示例4: LookupTopLevelMetadataType

 internal override NamedTypeSymbol LookupTopLevelMetadataType(ref MetadataTypeName emittedName)
 {
     return new MissingMetadataTypeSymbol.TopLevel(this, ref emittedName);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:MissingModuleSymbol.cs


示例5: FindMetadataTypeByMetadataTypeName

 private MetadataType FindMetadataTypeByMetadataTypeName(List<MetadataType> allTypes,
     MetadataTypeName metadataTypeName)
 {
     if (metadataTypeName == null)
         return null;
     var metaDataType = allTypes.Where(x => x.Name == metadataTypeName.Name &&
                                            x.Namespace == metadataTypeName.Namespace)
         .FirstNonDefault();
     return metaDataType;
 }
开发者ID:ServiceStack,项目名称:ServiceStack,代码行数:10,代码来源:TypeScriptGenerator.cs


示例6: LookupMetadataType

        internal NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emittedTypeName, out bool isNoPiaLocalType)
        {
            NamedTypeSymbol result = LookupMetadataType(ref emittedTypeName);
            isNoPiaLocalType = false;

            if (result is MissingMetadataTypeSymbol)
            {
                EnsureAllMembersLoaded();
                TypeDefinitionHandle typeDef;

                // See if this is a NoPia local type, which we should unify.
                // Note, VB should use FullName.
                if (_lazyNoPiaLocalTypes != null && _lazyNoPiaLocalTypes.TryGetValue(emittedTypeName.TypeName, out typeDef))
                {
                    result = (NamedTypeSymbol)new MetadataDecoder(ContainingPEModule).GetTypeOfToken(typeDef, out isNoPiaLocalType);
                    Debug.Assert(isNoPiaLocalType);
                }
            }

            return result;
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:21,代码来源:PENamespaceSymbol.cs


示例7: LookupAssemblyForForwardedMetadataType

        /// <summary>
        /// Look up the assembly to which the given metadata type is forwarded.
        /// </summary>
        /// <param name="emittedName"></param>
        /// <returns>
        /// The assembly to which the given type is forwarded or null, if there isn't one.
        /// </returns>
        /// <remarks>
        /// The returned assembly may also forward the type.
        /// </remarks>
        internal AssemblySymbol LookupAssemblyForForwardedMetadataType(ref MetadataTypeName emittedName)
        {
            // Look in the type forwarders of the primary module of this assembly, clr does not honor type forwarder
            // in non-primary modules.

            // Examine the type forwarders, but only from the primary module.
            return this.PrimaryModule.GetAssemblyForForwardedType(ref emittedName);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:18,代码来源:PEAssemblySymbol.cs


示例8: LookupMetadataType

        /// <summary>
        /// Lookup an immediately nested type referenced from metadata, names should be
        /// compared case-sensitively.
        /// </summary>
        /// <param name="emittedTypeName">
        /// Simple type name, possibly with generic name mangling.
        /// </param>
        /// <returns>
        /// Symbol for the type, or MissingMetadataSymbol if the type isn't found.
        /// </returns>
        internal virtual NamedTypeSymbol LookupMetadataType(ref MetadataTypeName emittedTypeName)
        {
            Debug.Assert(!emittedTypeName.IsNull);

            NamespaceOrTypeSymbol scope = this;

            if (scope.Kind == SymbolKind.ErrorType)
            {
                return new MissingMetadataTypeSymbol.Nested((NamedTypeSymbol)scope, ref emittedTypeName);
            }

            NamedTypeSymbol namedType = null;

            ImmutableArray<NamedTypeSymbol> namespaceOrTypeMembers;
            bool isTopLevel = scope.IsNamespace;

            Debug.Assert(!isTopLevel || scope.ToDisplayString(SymbolDisplayFormat.QualifiedNameOnlyFormat) == emittedTypeName.NamespaceName);

            if (emittedTypeName.IsMangled)
            {
                Debug.Assert(!emittedTypeName.UnmangledTypeName.Equals(emittedTypeName.TypeName) && emittedTypeName.InferredArity > 0);

                if (emittedTypeName.ForcedArity == -1 || emittedTypeName.ForcedArity == emittedTypeName.InferredArity)
                {
                    // Let's handle mangling case first.
                    namespaceOrTypeMembers = scope.GetTypeMembers(emittedTypeName.UnmangledTypeName);

                    foreach (var named in namespaceOrTypeMembers)
                    {
                        if (emittedTypeName.InferredArity == named.Arity && named.MangleName)
                        {
                            if ((object)namedType != null)
                            {
                                namedType = null;
                                break;
                            }

                            namedType = named;
                        }
                    }
                }
            }
            else
            {
                Debug.Assert(ReferenceEquals(emittedTypeName.UnmangledTypeName, emittedTypeName.TypeName) && emittedTypeName.InferredArity == 0);
            }

            // Now try lookup without removing generic arity mangling.
            int forcedArity = emittedTypeName.ForcedArity;

            if (emittedTypeName.UseCLSCompliantNameArityEncoding)
            {
                // Only types with arity 0 are acceptable, we already examined types with mangled names.
                if (emittedTypeName.InferredArity > 0)
                {
                    goto Done;
                }
                else if (forcedArity == -1)
                {
                    forcedArity = 0;
                }
                else if (forcedArity != 0)
                {
                    goto Done;
                }
                else
                {
                    Debug.Assert(forcedArity == emittedTypeName.InferredArity);
                }
            }

            namespaceOrTypeMembers = scope.GetTypeMembers(emittedTypeName.TypeName);

            foreach (var named in namespaceOrTypeMembers)
            {
                if (!named.MangleName && (forcedArity == -1 || forcedArity == named.Arity))
                {
                    if ((object)namedType != null)
                    {
                        namedType = null;
                        break;
                    }

                    namedType = named;
                }
            }

        Done:
            if ((object)namedType == null)
            {
//.........这里部分代码省略.........
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:101,代码来源:NamespaceOrTypeSymbol.cs


示例9: TopLevel

 public TopLevel(ModuleSymbol module, ref MetadataTypeName fullName)
     : this(module, ref fullName, -1)
 {
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:MissingMetadataTypeSymbol.cs


示例10: LookupMetadataType

 internal override NamedTypeSymbol LookupMetadataType(ref MetadataTypeName typeName)
 {
     return this.RetargetingTranslator.Retarget(this.underlyingType.LookupMetadataType(ref typeName), RetargetOptions.RetargetPrimitiveTypesByName);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:RetargetingNamedTypeSymbol.cs


示例11: LookupTopLevelMetadataTypeWithCycleDetection

 internal override NamedTypeSymbol LookupTopLevelMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol> visitedAssemblies, bool digThroughForwardedTypes)
 {
     var result = this.moduleSymbol.LookupTopLevelMetadataType(ref emittedName);
     Debug.Assert(result is MissingMetadataTypeSymbol);
     return result;
 }
开发者ID:Wazner,项目名称:roslyn,代码行数:6,代码来源:MissingAssemblySymbol.cs


示例12: TopLevelWithCustomErrorInfo

 public TopLevelWithCustomErrorInfo(ModuleSymbol module, ref MetadataTypeName emittedName, DiagnosticInfo errorInfo)
     : base(module, ref emittedName)
 {
     Debug.Assert(errorInfo != null);
     this.errorInfo = errorInfo;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:6,代码来源:MissingMetadataTypeSymbol.cs


示例13: LookupTopLevelMetadataTypeWithCycleDetection

        /// <summary>
        /// Lookup a top level type referenced from metadata, names should be
        /// compared case-sensitively.  Detect cycles during lookup.
        /// </summary>
        /// <param name="emittedName">
        /// Full type name, possibly with generic name mangling.
        /// </param>
        /// <param name="visitedAssemblies">
        /// List of assemblies lookup has already visited (since type forwarding can introduce cycles).
        /// </param>
        /// <param name="digThroughForwardedTypes">
        /// Take forwarded types into account.
        /// </param>
        internal sealed override NamedTypeSymbol LookupTopLevelMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol> visitedAssemblies, bool digThroughForwardedTypes)
        {
            NamedTypeSymbol result = null;

            // This is a cache similar to the one used by MetaImport::GetTypeByName in native
            // compiler. The difference is that native compiler pre-populates the cache when it
            // loads types. Here we are populating the cache only with things we looked for, so that
            // next time we are looking for the same thing, the lookup is fast. This cache also
            // takes care of TypeForwarders. Gives about 8% win on subsequent lookups in some
            // scenarios.     
            //    
            // CONSIDER !!!
            //
            // However, it is questionable how often subsequent lookup by name  is going to happen.
            // Currently it doesn't happen for TypeDef tokens at all, for TypeRef tokens, the
            // lookup by name is done once and the result is cached. So, multiple lookups by name
            // for the same type are going to happen only in these cases:
            // 1) Resolving GetType() in attribute application, type is encoded by name.
            // 2) TypeRef token isn't reused within the same module, i.e. multiple TypeRefs point to
            //    the same type.
            // 3) Different Module refers to the same type, lookup once per Module (with exception of #2).
            // 4) Multitargeting - retargeting the type to a different version of assembly
            result = LookupTopLevelMetadataTypeInCache(ref emittedName);

            if ((object)result != null)
            {
                // We only cache result equivalent to digging through type forwarders, which
                // might produce an forwarder specific ErrorTypeSymbol. We don't want to 
                // return that error symbol, unless digThroughForwardedTypes is true.
                if (digThroughForwardedTypes || (!result.IsErrorType() && (object)result.ContainingAssembly == (object)this))
                {
                    return result;
                }

                // According to the cache, the type wasn't found, or isn't declared in this assembly (forwarded).
                return new MissingMetadataTypeSymbol.TopLevel(this.Modules[0], ref emittedName);
            }
            else
            {
                // Now we will look for the type in each module of the assembly and pick the first type
                // we find, this is what native VB compiler does.

                var modules = this.Modules;
                var count = modules.Length;
                var i = 0;

                result = modules[i].LookupTopLevelMetadataType(ref emittedName);

                if (result is MissingMetadataTypeSymbol)
                {
                    for (i = 1; i < count; i++)
                    {
                        var newResult = modules[i].LookupTopLevelMetadataType(ref emittedName);

                        // Hold on to the first missing type result, unless we found the type.
                        if (!(newResult is MissingMetadataTypeSymbol))
                        {
                            result = newResult;
                            break;
                        }
                    }
                }

                bool foundMatchInThisAssembly = (i < count);

                Debug.Assert(!foundMatchInThisAssembly || (object)result.ContainingAssembly == (object)this);

                if (!foundMatchInThisAssembly && digThroughForwardedTypes)
                {
                    // We didn't find the type
                    System.Diagnostics.Debug.Assert(result is MissingMetadataTypeSymbol);

                    NamedTypeSymbol forwarded = TryLookupForwardedMetadataTypeWithCycleDetection(ref emittedName, visitedAssemblies);
                    if ((object)forwarded != null)
                    {
                        result = forwarded;
                    }
                }

                System.Diagnostics.Debug.Assert((object)result != null);

                // Add result of the lookup into the cache
                if (digThroughForwardedTypes || foundMatchInThisAssembly)
                {
                    CacheTopLevelMetadataType(ref emittedName, result);
                }

//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:101,代码来源:NonMissingAssemblySymbol.cs


示例14: CacheTopLevelMetadataType

 private void CacheTopLevelMetadataType(
     ref MetadataTypeName emittedName,
     NamedTypeSymbol result)
 {
     NamedTypeSymbol result1 = null;
     result1 = this.emittedNameToTypeMap.GetOrAdd(emittedName.ToKey(), result);
     System.Diagnostics.Debug.Assert(result1 == result); // object identity may differ in error cases
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:8,代码来源:NonMissingAssemblySymbol.cs


示例15: TryLookupForwardedMetadataTypeWithCycleDetection

 internal override NamedTypeSymbol TryLookupForwardedMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol> visitedAssemblies)
 {
     return null;
 }
开发者ID:Wazner,项目名称:roslyn,代码行数:4,代码来源:MockAssemblySymbol.cs


示例16: LookupTopLevelMetadataType

        /// <summary>
        /// Lookup a top level type referenced from metadata, names should be
        /// compared case-sensitively.
        /// </summary>
        /// <param name="emittedName">
        /// Full type name, possibly with generic name mangling.
        /// </param>
        /// <returns>
        /// Symbol for the type, or MissingMetadataSymbol if the type isn't found.
        /// </returns>
        /// <remarks></remarks>
        internal sealed override NamedTypeSymbol LookupTopLevelMetadataType(ref MetadataTypeName emittedName)
        {
            NamedTypeSymbol result;
            NamespaceSymbol scope = this.GlobalNamespace.LookupNestedNamespace(emittedName.NamespaceSegments);

            if ((object)scope == null)
            {
                // We failed to locate the namespace
                result = new MissingMetadataTypeSymbol.TopLevel(this, ref emittedName);
            }
            else
            {
                result = scope.LookupMetadataType(ref emittedName);
            }

            Debug.Assert((object)result != null);
            return result;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:NonMissingModuleSymbol.cs


示例17: TryLookupForwardedMetadataTypeWithCycleDetection

        internal override NamedTypeSymbol TryLookupForwardedMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol> visitedAssemblies)
        {
            NamedTypeSymbol underlying = _underlyingAssembly.TryLookupForwardedMetadataType(ref emittedName);

            if ((object)underlying == null)
            {
                return null;
            }

            return this.RetargetingTranslator.Retarget(underlying, RetargetOptions.RetargetPrimitiveTypesByName);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:RetargetingAssemblySymbol.cs


示例18: TryLookupForwardedMetadataTypeWithCycleDetection

        internal override NamedTypeSymbol TryLookupForwardedMetadataTypeWithCycleDetection(ref MetadataTypeName emittedName, ConsList<AssemblySymbol> visitedAssemblies)
        {
            // Check if it is a forwarded type.
            var forwardedToAssembly = LookupAssemblyForForwardedMetadataType(ref emittedName);
            if ((object)forwardedToAssembly != null)
            {
                // Don't bother to check the forwarded-to assembly if we've already seen it.
                if (visitedAssemblies != null && visitedAssemblies.Contains(forwardedToAssembly))
                {
                    return CreateCycleInTypeForwarderErrorTypeSymbol(ref emittedName);
                }
                else
                {
                    visitedAssemblies = new ConsList<AssemblySymbol>(this, visitedAssemblies ?? ConsList<AssemblySymbol>.Empty);
                    return forwardedToAssembly.LookupTopLevelMetadataTypeWithCycleDetection(ref emittedName, visitedAssemblies, digThroughForwardedTypes: true);
                }
            }

            return null;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:20,代码来源:PEAssemblySymbol.cs


示例19: GetAssemblyForForwardedType

 /// <summary>
 /// If this module forwards the given type to another assembly, return that assembly;
 /// otherwise, return null.
 /// </summary>
 /// <param name="fullName">Type to look up.</param>
 /// <returns>Assembly symbol or null.</returns>
 /// <remarks>
 /// The returned assembly may also forward the type.
 /// </remarks>
 internal AssemblySymbol GetAssemblyForForwardedType(ref MetadataTypeName fullName)
 {
     try
     {
         string matchedName;
         AssemblyReferenceHandle assemblyRef = Module.GetAssemblyForForwardedType(fullName.FullName, ignoreCase: false, matchedName: out matchedName);
         return assemblyRef.IsNil ? null : this.GetReferencedAssemblySymbols()[Module.GetAssemblyReferenceIndexOrThrow(assemblyRef)];
     }
     catch (BadImageFormatException)
     {
         return null;
     }
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:22,代码来源:PEModuleSymbol.cs


示例20: TopLevelWithCustomErrorInfo

 public TopLevelWithCustomErrorInfo(ModuleSymbol module, ref MetadataTypeName emittedName, DiagnosticInfo errorInfo, WellKnownType typeId)
     : base(module, ref emittedName, typeId)
 {
     Debug.Assert(errorInfo != null);
     _errorInfo = errorInfo;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:6,代码来源:MissingMetadataTypeSymbol.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MetadataTypes类代码示例发布时间:2022-05-24
下一篇:
C# MetadataType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap