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


C# MetadataReferenceProperties类代码示例

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


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

示例1: ResolveReference

        public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            Dictionary<string, PortableExecutableReference> map;

            if (PathUtilities.IsFilePath(reference))
            {
                if (_pathResolver != null)
                {
                    reference = _pathResolver.ResolvePath(reference, baseFilePath);
                    if (reference == null)
                    {
                        return ImmutableArray<PortableExecutableReference>.Empty;
                    }
                }

                map = _files;
            }
            else
            {
                map = _assemblyNames;
            }

            PortableExecutableReference result;
            return map.TryGetValue(reference, out result) ? ImmutableArray.Create(result) : ImmutableArray<PortableExecutableReference>.Empty;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:TestMetadataReferenceResolver.cs

示例2: GetMetadata

        internal Metadata GetMetadata(string fullPath, MetadataReferenceProperties properties)
        {
            // Check if we have an entry in the dictionary.
            FileKey? fileKey = GetUniqueFileKey(fullPath);

            Metadata metadata;
            if (fileKey.HasValue && metadataCache.TryGetValue(fileKey.Value, out metadata) && metadata != null)
            {
                CompilerServerLogger.Log("Using already loaded metadata for assembly reference '{0}'", fileKey);
                return metadata;
            }

            if (properties.Kind == MetadataImageKind.Module)
            {
                var result = CreateModuleMetadata(fullPath, prefetchEntireImage: true);
                //?? never add modules to cache?
                return result;
            }
            else
            {
                var primaryModule = CreateModuleMetadata(fullPath, prefetchEntireImage: false);

                // Get all the modules, and load them. Create an assembly metadata.
                var allModules = GetAllModules(primaryModule, Path.GetDirectoryName(fullPath));
                Metadata result = AssemblyMetadata.Create(allModules);

                result = metadataCache.GetOrAdd(fileKey.Value, result);

                return result;
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:31,代码来源:MetadataCache.cs

示例3: GetAddOrUpdate

            public MetadataReference GetAddOrUpdate(string path, MetadataReferenceProperties properties)
            {
                using (_gate.DisposableWait())
                {
                    WeakReference<MetadataReference> weakref;
                    MetadataReference mref = null;

                    if (!(_references.TryGetValue(properties, out weakref) && weakref.TryGetTarget(out mref)))
                    {
                        // try to base this metadata reference off of an existing one, so we don't load the metadata bytes twice.
                        foreach (var wr in _references.Values)
                        {
                            if (wr.TryGetTarget(out mref))
                            {
                                mref = mref.WithProperties(properties);
                                break;
                            }
                        }

                        if (mref == null)
                        {
                            mref = _cache._createReference(path, properties);
                        }

                        _references[properties] = new WeakReference<MetadataReference>(mref);
                    }

                    return mref;
                }
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:30,代码来源:MetadataReferenceCache.cs

示例4: MetadataFileReference

 public MetadataFileReference(string fullPath, MetadataReferenceProperties properties, DocumentationProvider documentation = null)
     : base(properties, fullPath, initialDocumentation: documentation ?? DocumentationProvider.Default)
 {
     if (fullPath == null)
     {
         throw new ArgumentNullException("fullPath");
     }
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:8,代码来源:MetadataFileReference.cs

示例5: ShadowCopyReference

            public ShadowCopyReference(MetadataShadowCopyProvider provider, string originalPath, MetadataReferenceProperties properties)
                : base(properties, originalPath)
            {
                Debug.Assert(originalPath != null);
                Debug.Assert(provider != null);

                _provider = provider;
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:InteractiveHost.ShadowCopyReference.cs

示例6: GetReference

        public MetadataReference GetReference(string path, MetadataReferenceProperties properties)
        {
            if (!_referenceSets.TryGetValue(path, out var referenceSet))
            {
                referenceSet = ImmutableInterlocked.GetOrAdd(ref _referenceSets, path, new ReferenceSet(this));
            }

            return referenceSet.GetAddOrUpdate(path, properties);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:9,代码来源:MetadataReferenceCache.cs

示例7: WithProperties

        /// <summary>
        /// Returns an instance of the reference with specified properties, or this instance if properties haven't changed.
        /// </summary>
        /// <param name="properties">The new properties for the reference.</param>
        /// <exception cref="ArgumentException">Specified values not valid for this reference.</exception>
        public MetadataReference WithProperties(MetadataReferenceProperties properties)
        {
            if (properties == this.Properties)
            {
                return this;
            }

            return WithPropertiesImplReturningMetadataReference(properties);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:14,代码来源:MetadataReference.cs

示例8: PortableExecutableReference

 protected PortableExecutableReference(
     MetadataReferenceProperties properties,
     string fullPath = null,
     DocumentationProvider initialDocumentation = null)
     : base(properties)
 {
     _filePath = fullPath;
     _lazyDocumentation = initialDocumentation;
 }
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:9,代码来源:PortableExecutableReference.cs

示例9: WithPropertiesImpl

 protected override PortableExecutableReference WithPropertiesImpl(MetadataReferenceProperties properties)
 {
     return new MetadataImageReference(
         _metadata,
         properties,
         this.DocumentationProvider,
         this.FilePath,
         _display);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:MetadataImageReference.cs

示例10: ResolveReference

        public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            var path = PathResolver.ResolveReference(reference, baseFilePath);
            if (path == null)
            {
                return ImmutableArray<PortableExecutableReference>.Empty;
            }

            return ImmutableArray.Create(Provider.GetReference(path, properties));
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:10,代码来源:AssemblyReferenceResolver.cs

示例11: GetReference

            public override PortableExecutableReference GetReference(string fullPath, MetadataReferenceProperties properties = default(MetadataReferenceProperties))
            {
                AssemblyMetadata metadata;
                if (_cache.TryGetValue(fullPath, out metadata))
                {
                    return metadata.GetReference(MakeDocumentationProvider());
                }

                _cache.Add(fullPath, metadata = AssemblyMetadata.CreateFromFile(fullPath));
                return metadata.GetReference(MakeDocumentationProvider());
            }
开发者ID:noahstein,项目名称:roslyn,代码行数:11,代码来源:InteractiveSessionTests.cs

示例12: ResolveReference

        public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties)
        {
            // Note: currently not handling relative paths, since we don't have tests that use them

            if (File.Exists(reference))
            {
                return ImmutableArray.Create(MetadataReference.CreateFromFile(reference, properties));
            }

            return default(ImmutableArray<PortableExecutableReference>);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:TestRuntimeMetadataReferenceResolver.cs

示例13: AddProjectReference

 public void AddProjectReference(IProjectContext project, MetadataReferenceProperties properties)
 {
     // AbstractProject and ProjectTracker track project references using the project bin output path.
     // Setting the command line arguments should have already set the output file name and folder.
     // We fetch this output path to add the reference.
     var referencedProject = this.ProjectTracker.GetProject(project.Id);
     var binPathOpt = referencedProject.TryGetBinOutputPath();
     if (!string.IsNullOrEmpty(binPathOpt))
     {
         AddMetadataReferenceAndTryConvertingToProjectReferenceIfPossible(binPathOpt, properties);
     }
 }
开发者ID:xyh413,项目名称:roslyn,代码行数:12,代码来源:CPSProject_IProjectContext.cs

示例14: WithProperties

        /// <summary>
        /// Returns an instance of the reference with specified properties, or this instance if properties haven't changed.
        /// </summary>
        /// <param name="properties">The new properties for the reference.</param>
        /// <exception cref="ArgumentException">Specified values not valid for this reference.</exception> 
        public new CompilationReference WithProperties(MetadataReferenceProperties properties)
        {
            if (properties == this.Properties)
            {
                return this;
            }

            if (properties.Kind == MetadataImageKind.Module)
            {
                throw new ArgumentException(CodeAnalysisResources.CannotCreateReferenceToModule);
            }

            return WithPropertiesImpl(properties);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:19,代码来源:CompilationReference.cs

示例15: WithXxx

        public void WithXxx()
        {
            var p = new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a"), embedInteropTypes: false);

            Assert.Equal(p.WithAliases(null), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray<string>.Empty, embedInteropTypes: false));
            Assert.Equal(p.WithAliases(default(ImmutableArray<string>)), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray<string>.Empty, embedInteropTypes: false));
            Assert.Equal(p.WithAliases(ImmutableArray<string>.Empty), new MetadataReferenceProperties(MetadataImageKind.Assembly, default(ImmutableArray<string>), embedInteropTypes: false));
            Assert.Equal(p.WithAliases(new string[0]), new MetadataReferenceProperties(MetadataImageKind.Assembly, default(ImmutableArray<string>), embedInteropTypes: false));
            Assert.Equal(p.WithAliases(new[] { "foo", "aaa" }), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("foo", "aaa"), embedInteropTypes: false));
            Assert.Equal(p.WithEmbedInteropTypes(true), new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a"), embedInteropTypes: true));

            var m = new MetadataReferenceProperties(MetadataImageKind.Module);
            Assert.Equal(m.WithAliases(default(ImmutableArray<string>)), new MetadataReferenceProperties(MetadataImageKind.Module, default(ImmutableArray<string>), embedInteropTypes: false));
            Assert.Equal(m.WithEmbedInteropTypes(false), new MetadataReferenceProperties(MetadataImageKind.Module, default(ImmutableArray<string>), embedInteropTypes: false));
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:15,代码来源:MetadataReferencePropertiesTests.cs


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