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


C# MetadataTypeName类代码示例

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


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


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