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

C# LibraryRange类代码示例

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

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



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

示例1: RuntimeStyleLibraryRangeToString

        // DNU REFACTORING TODO: temp hack to make generated lockfile work with runtime lockfile validation
        private static string RuntimeStyleLibraryRangeToString(LibraryRange libraryRange)
        {
            var sb = new StringBuilder();
            sb.Append(libraryRange.Name);
            sb.Append(" ");

            if (libraryRange.VersionRange == null)
            {
                return sb.ToString();
            }

            var minVersion = libraryRange.VersionRange.MinVersion;
            var maxVersion = libraryRange.VersionRange.MaxVersion;

            sb.Append(">= ");

            if (libraryRange.VersionRange.IsFloating)
            {
                sb.Append(libraryRange.VersionRange.Float.ToString());
            }
            else
            {
                sb.Append(minVersion.ToString());
            }

            if (maxVersion != null)
            {
                sb.Append(libraryRange.VersionRange.IsMaxInclusive ? "<= " : "< ");
                sb.Append(maxVersion.Version.ToString());
            }

            return sb.ToString();
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:34,代码来源:LockFile.cs


示例2: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            if (!libraryRange.IsGacOrFrameworkReference)
            {
                return null;
            }

            if (!RuntimeEnvironmentHelper.IsWindows)
            {
                return null;
            }

            if (!VersionUtility.IsDesktop(targetFramework))
            {
                return null;
            }

            var name = libraryRange.Name;
            var version = libraryRange.VersionRange?.MinVersion;

            string path;
            if (!TryResolvePartialName(libraryRange.GetReferenceAssemblyName(), version, targetFramework, out path))
            {
                return null;
            }

            return new LibraryDescription(
                libraryRange,
                new LibraryIdentity(name, version, isGacOrFrameworkReference: true),
                path,
                LibraryTypes.GlobalAssemblyCache,
                Enumerable.Empty<LibraryDependency>(),
                new[] { libraryRange.GetReferenceAssemblyName() },
                framework: targetFramework);
        }
开发者ID:leloulight,项目名称:dnx,代码行数:35,代码来源:GacDependencyResolver.cs


示例3: GetLibrary

        public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            var package = FindCandidate(libraryRange.Name, libraryRange.VersionRange);

            if (package != null)
            {
                NuspecReader nuspecReader = null;
                using (var stream = File.OpenRead(package.ManifestPath))
                {
                    nuspecReader = new NuspecReader(stream);
                }

                var description = new Library
                    {
                        LibraryRange = libraryRange,
                        Identity = new LibraryIdentity
                            {
                                Name = package.Id,
                                Version = package.Version,
                                Type = LibraryTypes.Package
                            },
                        Path = package.ManifestPath,
                        Dependencies = GetDependencies(nuspecReader, targetFramework)
                    };

                description.Items["package"] = package;
                description.Items["metadata"] = nuspecReader;

                return description;
            }

            return null;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:33,代码来源:NuGetDependencyResolver.cs


示例4: FindLibrary

        public async Task<WalkProviderMatch> FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework, bool includeUnlisted)
        {
            var results = await _source.FindPackagesByIdAsync(libraryRange.Name);
            PackageInfo bestResult = null;
            if(!includeUnlisted)
            {
                results = results.Where(p => p.Listed);
            }

            foreach (var result in results)
            {
                if (VersionUtility.ShouldUseConsidering(
                    current: bestResult?.Version,
                    considering: result.Version,
                    ideal: libraryRange.VersionRange))
                {
                    bestResult = result;
                }
            }

            if (bestResult == null)
            {
                return null;
            }

            return new WalkProviderMatch
            {
                Library = new LibraryIdentity(bestResult.Id, bestResult.Version, isGacOrFrameworkReference: false),
                Path = bestResult.ContentUri,
                Provider = this,
            };
        }
开发者ID:henghu-bai,项目名称:dnx,代码行数:32,代码来源:RemoteWalkProvider.cs


示例5: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            if (!DependencyTargets.SupportsPackage(libraryRange.Target))
            {
                return null;
            }

            var versionRange = libraryRange.VersionRange;

            var package = FindCandidate(libraryRange.Name, versionRange);

            if (package != null)
            {
                var dependencies = GetDependencies(package, targetFramework);

                return new LibraryDescription(
                    libraryRange,
                    new LibraryIdentity(package.Id, package.Version, isGacOrFrameworkReference: false),
                    path: null,
                    type: LibraryTypes.Package,
                    dependencies: dependencies,
                    assemblies: null,
                    framework: null);
            }

            return null;
        }
开发者ID:rajeevkb,项目名称:dnx,代码行数:27,代码来源:NuGetDependencyResolver.cs


示例6: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            if (!LibraryType.ReferenceAssembly.CanSatisfyConstraint(libraryRange.Target))
            {
                return null;
            }

            var name = libraryRange.Name;
            var version = libraryRange.VersionRange?.MinVersion;

            string path;
            Version assemblyVersion;

            if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
            {
                return null;
            }

            return new LibraryDescription(
                new LibraryIdentity(libraryRange.Name, new NuGetVersion(assemblyVersion), LibraryType.ReferenceAssembly),
                string.Empty, // Framework assemblies don't have hashes
                path,
                Enumerable.Empty<LibraryRange>(),
                targetFramework,
                resolved: true,
                compatible: true);
        }
开发者ID:kyulee1,项目名称:cli,代码行数:27,代码来源:ReferenceAssemblyDependencyResolver.cs


示例7: FindLibrary

        public async Task<WalkProviderMatch> FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            var results = await _source.FindPackagesByIdAsync(libraryRange.Name);
            PackageInfo bestResult = null;
            foreach (var result in results)
            {
                if (VersionUtility.ShouldUseConsidering(
                    current: bestResult?.Version,
                    considering: result.Version,
                    ideal: libraryRange.VersionRange))
                {
                    bestResult = result;
                }
            }

            if (bestResult == null)
            {
                return null;
            }

            return new WalkProviderMatch
            {
                Library = new Library
                {
                    Name = bestResult.Id,
                    Version = bestResult.Version
                },
                Path = bestResult.ContentUri,
                Provider = this,
            };
        }
开发者ID:nagyistoce,项目名称:dnx,代码行数:31,代码来源:RemoteWalkProvider.cs


示例8: GetDescription

        public Library GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            Debug.Assert(SupportsType(libraryRange.TypeConstraint));

            var name = libraryRange.Name;
            var version = libraryRange.VersionRange?.MinVersion;

            string path;
            NuGetVersion assemblyVersion;

            if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
            {
                Log.LogWarning($"Unable to resolve requested assembly {libraryRange.Name}");
                return null;
            }

            if (version == null || version == assemblyVersion)
            {
                return new Library
                {
                    LibraryRange = libraryRange,
                    Identity = new LibraryIdentity
                    {
                        Name = name,
                        Version = assemblyVersion,
                        Type = LibraryTypes.Reference
                    },
                    Dependencies = Enumerable.Empty<LibraryDependency>(),

                    [KnownLibraryProperties.AssemblyPath] = path
                };
            }

            return null;
        }
开发者ID:elanwu123,项目名称:dnx,代码行数:35,代码来源:ReferenceAssemblyDependencyProvider.cs


示例9: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            if (!libraryRange.IsGacOrFrameworkReference)
            {
                return null;
            }

            var name = libraryRange.GetReferenceAssemblyName();
            var version = libraryRange.VersionRange?.MinVersion;

            string path;
            Version assemblyVersion;

            if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
            {
                return null;
            }

            if (version == null || version.Version == assemblyVersion)
            {
                return new LibraryDescription(
                    libraryRange,
                    new LibraryIdentity(libraryRange.Name, new SemanticVersion(assemblyVersion), isGacOrFrameworkReference: true),
                    path,
                    LibraryTypes.ReferenceAssembly,
                    Enumerable.Empty<LibraryDependency>(),
                    new[] { name },
                    framework: targetFramework);
            }

            return null;
        }
开发者ID:rajeevkb,项目名称:dnx,代码行数:32,代码来源:ReferenceAssemblyDependencyResolver.cs


示例10: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            if (libraryRange.IsGacOrFrameworkReference)
            {
                return null;
            }

            if (!DependencyTargets.SupportsProject(libraryRange.Target))
            {
                return null;
            }

            string name = libraryRange.Name;

            Runtime.Project project;

            // Can't find a project file with the name so bail
            if (!_projectResolver.TryResolveProject(name, out project))
            {
                return null;
            }

            // This never returns null
            var targetFrameworkInfo = project.GetCompatibleTargetFramework(targetFramework);

            var dependencies = project.Dependencies.Concat(targetFrameworkInfo.Dependencies).ToList();
            
            return new ProjectDescription(
                libraryRange,
                project,
                dependencies,
                Enumerable.Empty<string>(),
                targetFrameworkInfo,
                resolved: true);
        }
开发者ID:leloulight,项目名称:dnx,代码行数:35,代码来源:ProjectReferenceDependencyProvider.cs


示例11: GetLibrary

        public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            var key = Tuple.Create(targetFramework, libraryRange.Name);
            LockFileTargetLibrary library = null;

            // Determine if we have a library for this target
            if (_targetLibraries.TryGetValue(key, out library) &&
                libraryRange.VersionRange.IsBetter(current: null, considering: library.Version))
            {
                var dependencies = GetDependencies(library, targetFramework);

                var description = new Library {
                    LibraryRange = libraryRange,
                    Identity = new LibraryIdentity
                    {
                        Name = library.Name,
                        Version = library.Version,
                        Type = LibraryTypes.Package
                    },
                    Resolved = true,
                    Dependencies = dependencies,

                    [KnownLibraryProperties.LockFileLibrary] = _libraries[Tuple.Create(library.Name, library.Version)],
                    [KnownLibraryProperties.LockFileTargetLibrary] = library
                };
                
                return description;
            }

            return null;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:31,代码来源:LockFileDependencyProvider.cs


示例12: GetLibrary

        public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
        {
            ExternalProjectReference externalProject;
            if (!ExternalProjects.TryGetValue(libraryRange.Name, out externalProject))
            {
                // No project!
                return null;
            }

            // Fill dependencies from external project references
            var dependencies = externalProject.ExternalProjectReferences.Select(s => new LibraryDependency()
                {
                    LibraryRange = new LibraryRange()
                        {
                            Name = s,
                            VersionRange = null,
                            TypeConstraint = LibraryTypes.ExternalProject
                        },
                    Type = LibraryDependencyType.Default
                }).ToList();

            // Add dependencies from the nuget.json file
            if (!string.IsNullOrEmpty(externalProject.PackageSpecPath)
                && File.Exists(externalProject.PackageSpecPath))
            {
                PackageSpec packageSpec;
                using (var stream = new FileStream(externalProject.PackageSpecPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    packageSpec = JsonPackageSpecReader.GetPackageSpec(stream, externalProject.Name, externalProject.PackageSpecPath);
                }

                // Add framework-agnostic dependencies
                dependencies.AddRange(packageSpec.Dependencies);

                // Add framework-specific dependencies
                var frameworkInfo = packageSpec.GetTargetFramework(targetFramework);
                if (frameworkInfo != null)
                {
                    dependencies.AddRange(frameworkInfo.Dependencies);
                }
            }

            // Construct the library and return it
            return new Library()
                {
                    Identity = new LibraryIdentity()
                        {
                            Name = externalProject.Name,
                            Version = new NuGetVersion("1.0.0"),
                            Type = LibraryTypes.ExternalProject
                        },
                    LibraryRange = libraryRange,
                    Dependencies = dependencies,
                    Path = externalProject.PackageSpecPath,
                    Resolved = true
                };
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:57,代码来源:ExternalProjectReferenceDependencyProvider.cs


示例13: GetDependencyItem

 private static DependencyItem GetDependencyItem(LibraryRange dependency,
                                                 IDictionary<string, LibraryExport> exportsLookup)
 {
     return new DependencyItem
     {
         Name = dependency.Name,
         Version = exportsLookup[dependency.Name].Library.Identity.Version?.ToNormalizedString()
     };
 }
开发者ID:noahfalk,项目名称:cli,代码行数:9,代码来源:DependencyDescription.cs


示例14: RunPackageInstall

        public static int RunPackageInstall(LibraryRange dependency, string projectPath, IEnumerable<string> args)
        {
            var result = RunDnx(new List<string> { "install", dependency.Name, dependency.VersionRange.OriginalString, projectPath }.Concat(args))
                .ForwardStdErr()
                .ForwardStdOut()
                .Execute();

            return result.ExitCode;
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:9,代码来源:Dnx.cs


示例15: RenderDependency

        private string RenderDependency(LibraryRange arg)
        {
            var name = arg.Name;

            if (arg.Target == LibraryType.ReferenceAssembly)
            {
                name = $"fx/{name}";
            }

            return $"{name} {VersionUtility.RenderVersion(arg.VersionRange)}";
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:11,代码来源:LockFile.cs


示例16: GetDescription

 public static LibraryDescription GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
 {
     return new LibraryDescription(
         new LibraryIdentity(libraryRange.Name, libraryRange.VersionRange?.MinVersion, libraryRange.Target),
         hash: null,
         path: null,
         dependencies: Enumerable.Empty<LibraryRange>(),
         framework: targetFramework,
         resolved: false,
         compatible: true);
 }
开发者ID:yonglehou,项目名称:docfx,代码行数:11,代码来源:UnresolvedDependencyProvider.cs


示例17: FindLibraryAsync

        public Task<LibraryIdentity> FindLibraryAsync(LibraryRange libraryRange, NuGetFramework targetFramework, CancellationToken cancellationToken)
        {
            var library = _dependencyProvider.GetLibrary(libraryRange, targetFramework);

            if (library == null)
            {
                return Task.FromResult<LibraryIdentity>(null);
            }

            return Task.FromResult(library.Identity);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:11,代码来源:LocalDependencyProvider.cs


示例18: GetDescription

        public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
        {
            if (libraryRange.IsGacOrFrameworkReference)
            {
                return null;
            }

            if (!DependencyTargets.SupportsProject(libraryRange.Target))
            {
                return null;
            }

            string name = libraryRange.Name;

            Runtime.Project project;

            // Can't find a project file with the name so bail
            if (!_projectResolver.TryResolveProject(name, out project))
            {
                return null;
            }

            // This never returns null
            var targetFrameworkInfo = project.GetCompatibleTargetFramework(targetFramework);

            var dependencies = project.Dependencies.Concat(targetFrameworkInfo.Dependencies).ToList();

            if (!dependencies.Any(d => d.Name.Equals(ImplicitPackagesWalkProvider.ImplicitRuntimePackageId)))
            {
                dependencies.Add(new LibraryDependency()
                {
                    LibraryRange = new LibraryRange(ImplicitPackagesWalkProvider.ImplicitRuntimePackageId, frameworkReference: false)
                    {
                        VersionRange = new SemanticVersionRange()
                        {
                            MinVersion = ImplicitPackagesWalkProvider.ImplicitRuntimePackageVersion,
                            MaxVersion = ImplicitPackagesWalkProvider.ImplicitRuntimePackageVersion,
                            IsMaxInclusive = true,
                            VersionFloatBehavior = SemanticVersionFloatBehavior.None
                        }
                    }
                });
            }

            return new ProjectDescription(
                libraryRange,
                project,
                dependencies,
                Enumerable.Empty<string>(),
                targetFrameworkInfo,
                resolved: true);
        }
开发者ID:rajeevkb,项目名称:dnx,代码行数:52,代码来源:ProjectReferenceDependencyProvider.cs


示例19: GetDescription

 public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
 {
     return new LibraryDescription(
         libraryRange,
         new LibraryIdentity(libraryRange.Name, libraryRange.VersionRange?.MinVersion, libraryRange.IsGacOrFrameworkReference),
         path: null,
         type: LibraryTypes.Unresolved,
         dependencies: Enumerable.Empty<LibraryDependency>(),
         assemblies: Enumerable.Empty<string>(),
         framework: null)
     {
         Resolved = false
     };
 }
开发者ID:henghu-bai,项目名称:dnx,代码行数:14,代码来源:UnresolvedDependencyProvider.cs


示例20: GetDescription

 public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
 {
     return new LibraryDescription
     {
         LibraryRange = libraryRange,
         Identity = new Library
         {
             Name = libraryRange.Name,
             IsGacOrFrameworkReference = libraryRange.IsGacOrFrameworkReference,
             Version = libraryRange.VersionRange?.MinVersion
         },
         Dependencies = Enumerable.Empty<LibraryDependency>(),
         Resolved = false
     };
 }
开发者ID:elanwu123,项目名称:dnx,代码行数:15,代码来源:UnresolvedDependencyProvider.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LibraryServices类代码示例发布时间:2022-05-24
下一篇:
C# LibraryChannel类代码示例发布时间: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