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

C# PackageDependency类代码示例

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

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



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

示例1: Upgrade

        public override bool Upgrade(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, IList<PackageLoadingAssetFile> assetFiles)
        {
            // Paradox 1.1 projects didn't have their dependency properly updated (they might have been marked as 1.0).
            // We know they are 1.1 only because there is a .props file.
            // This check shouldn't be necessary from 1.2.
            var packagePath = dependentPackage.FullPath;
            var propsFilePath = UPath.Combine(packagePath.GetParent(), (UFile)(packagePath.GetFileName() + ".props"));
            if (!File.Exists(propsFilePath) && dependency.Version.MinVersion < new PackageVersion("1.1.0-beta"))
            {
                log.Error("Can't upgrade old projects from {0} 1.0 to 1.1", dependency.Name);
                return false;
            }

            // Nothing to do for now, most of the work is already done by individual asset upgraders
            // We can later add logic here for package-wide upgrades (i.e. GameSettingsAsset)
            if (dependency.Version.MinVersion < new PackageVersion("1.2.0-beta"))
            {
                // UIImageGroups and SpriteGroups asset have been merged into a single SpriteSheet => rename the assets and modify the tag
                var uiImageGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxuiimage");
                var spitesGroups = assetFiles.Where(f => f.FilePath.GetFileExtension() == ".pdxsprite");
                RenameAndChangeTag(assetFiles, uiImageGroups, "!UIImageGroup");
                RenameAndChangeTag(assetFiles, spitesGroups, "!SpriteGroup");
            }

            return true;
        }
开发者ID:hck509,项目名称:paradox,代码行数:26,代码来源:ParadoxPackageUpgrader.cs


示例2: CreateTestPackage

        /// <summary>
        /// Creates a test package.
        /// </summary>
        /// <param name="packageId">The id of the created package.</param>
        /// <param name="version">The version of the created package.</param>
        /// <param name="path">The directory where the package is created.</param>
        /// <returns>The full path of the created package file.</returns>
        public static string CreateTestPackage(string packageId, string version, string path, Uri licenseUrl = null)
        {
            var packageBuilder = new PackageBuilder
            {
                Id = packageId,
                Version = new SemanticVersion(version),
                Description = "Test desc"
            };

            if (licenseUrl != null)
            {
                packageBuilder.LicenseUrl = licenseUrl;
            }

            var dependencies = new PackageDependency("Dummy");
            packageBuilder.DependencySets.Add(new PackageDependencySet(null, new[] { dependencies }));
            packageBuilder.Authors.Add("test author");

            var packageFileName = string.Format("{0}.{1}.nupkg", packageId, version);
            var packageFileFullPath = Path.Combine(path, packageFileName);
            using (var fileStream = File.Create(packageFileFullPath))
            {
                packageBuilder.Save(fileStream);
            }

            return packageFileFullPath;
        }
开发者ID:kumavis,项目名称:NuGet,代码行数:34,代码来源:Util.cs


示例3: IsPrereleaseDependency

        private static bool IsPrereleaseDependency(PackageDependency pd)
        {
            if (pd.VersionSpec == null)
            {
                return false;
            }

            return IsPreReleasedVersion(pd.VersionSpec.MinVersion) || IsPreReleasedVersion(pd.VersionSpec.MaxVersion);
        }
开发者ID:BreeeZe,项目名称:NuGetPackageExplorer,代码行数:9,代码来源:PrereleasePackageDependencyRule.cs


示例4: SinglePackageReturnsPackage

        public void SinglePackageReturnsPackage()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act   
            string installList = packageDependency.GetInstallListFromDependencies(new string[] { "NLog: " });

            // Assert
            Assert.AreEqual(installList, "NLog");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:11,代码来源:PackageDependencyTests.cs


示例5: ThreePackagesOneDependencyReturnsCorrectOrder

        public void ThreePackagesOneDependencyReturnsCorrectOrder()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act  
            string installList = packageDependency.GetInstallListFromDependencies
                (new string[] {"NLog.Config: NLog", "EntityFramework: ", "NLog: "});

            // Assert
            Assert.AreEqual(installList, "NLog, NLog.Config, EntityFramework");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:12,代码来源:PackageDependencyTests.cs


示例6: ThreePackagesTwoDependenciesReturnsCorrectOrder

        public void ThreePackagesTwoDependenciesReturnsCorrectOrder()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act  
            string installList = packageDependency.GetInstallListFromDependencies
                (new string[] { "NLog.Web: NLog.Test", "NLog.Test: NLog.HTTP","NLog.HTTP: ", "NLog.Web: " });

            // Assert
            Assert.AreEqual(installList, "NLog.HTTP, NLog.Test, NLog.Web");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:12,代码来源:PackageDependencyTests.cs


示例7: CreatePackageIssue

 private static PackageIssue CreatePackageIssue(PackageDependency target)
 {
     return new PackageIssue(
         PackageIssueLevel.Error,
         "Invalid prerelease dependency",
         String.Format(CultureInfo.CurrentCulture,
                       "A stable release of a package must not have a dependency on a prerelease package, '{0}'.",
                       target),
         String.Format(CultureInfo.CurrentCulture,
                       "Either modify the version spec of dependency '{0}' or update the version field.", target)
         );
 }
开发者ID:BreeeZe,项目名称:NuGetPackageExplorer,代码行数:12,代码来源:PrereleasePackageDependencyRule.cs


示例8: FourPackagesThreeDependenciesMixedOrderReturnsCorrectOrder

        public void FourPackagesThreeDependenciesMixedOrderReturnsCorrectOrder()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act  
            string installList = packageDependency.GetInstallListFromDependencies(new string[]
                                    { "NLog.HTTP: NLog.Test", "NLog.Config: ",
                                        "NLog.Test: NLog.Web", "NLog.Web: NLog.Config"});            

            // Assert
            Assert.AreEqual(installList, "NLog.Config, NLog.Web, NLog.Test, NLog.HTTP");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:13,代码来源:PackageDependencyTests.cs


示例9: CuratedFeedSatisfiesDependency

    private static bool CuratedFeedSatisfiesDependency(SemanticVersion curatedFeedVersion, PackageDependency dependency)
    {
      var dependencyVersion = dependency.VersionSpec;
      if (dependencyVersion == null)
        return true;

      IVersionSpec dependencyVersionSpec;
      if (!VersionUtility.TryParseVersionSpec(dependency.VersionSpec, out dependencyVersionSpec))
        return false;

      return dependencyVersionSpec.Satisfies(curatedFeedVersion)
        || StripPatchLevel(dependencyVersionSpec).Satisfies(curatedFeedVersion);
    }
开发者ID:JetBrains,项目名称:ReSharperGallery,代码行数:13,代码来源:RequiredDependencyPackageCurator.cs


示例10: UpgradeAfterAssetsLoaded

        /// <inheritdoc/>
        public override bool UpgradeAfterAssetsLoaded(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, PackageVersionRange dependencyVersionBeforeUpdate)
        {
            if (dependencyVersionBeforeUpdate.MinVersion < new PackageVersion("1.3.0-alpha02"))
            {
                // Add everything as root assets (since we don't know what the project was doing in the code before)
                foreach (var assetItem in dependentPackage.Assets)
                {
                    if (!AssetRegistry.IsAssetTypeAlwaysMarkAsRoot(assetItem.Asset.GetType()))
                        dependentPackage.RootAssets.Add(new AssetReference<Asset>(assetItem.Id, assetItem.Location));
                }
            }

            return true;
        }
开发者ID:RxGamesLtd,项目名称:paradox,代码行数:15,代码来源:ParadoxPackageUpgrader.cs


示例11: CreatePackageDependencyInfo

        private static PackageDependencyInfo CreatePackageDependencyInfo(PackageIdentity packageIdentity, params string[] dependencies)
        {
            if(dependencies != null && dependencies.Length % 2 != 0)
            {
                throw new ArgumentException("dependencies array length should be even");
            }

            List<PackageDependency> dependencyList = new List<PackageDependency>();
            if(dependencies != null)
            {
                for (int i = 0; i < dependencies.Length; i += 2)
                {
                    var packageDependency = new PackageDependency(dependencies[i], VersionRange.Parse(dependencies[i+1]));
                    dependencyList.Add(packageDependency);
                }
            }

            return new PackageDependencyInfo(packageIdentity, dependencyList);
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:19,代码来源:UninstallResolverTests.cs


示例12: GetPackageDependenciesFromPackagesConfig

 public IEnumerable<PackageDependency> GetPackageDependenciesFromPackagesConfig(XDocument packagesConfigXml)
 {
     List<PackageDependency> packageDependencies = new List<PackageDependency>();
     if (packagesConfigXml.Root != null)
     {
         foreach (XElement packageElement in packagesConfigXml.Root.Elements("package"))
         {
             XAttribute idAttribute = packageElement.Attribute("id");
             XAttribute versionAttribute = packageElement.Attribute("version");
             if (idAttribute != null && versionAttribute != null)
             {
                 string id = idAttribute.Value;
                 IVersionSpec versionSpec = new VersionSpec(new SemanticVersion(versionAttribute.Value));
                 PackageDependency packageInfo = new PackageDependency(id, versionSpec);
                 packageDependencies.Add(packageInfo);
             }
         }
     }
     return packageDependencies;
 }
开发者ID:xavierdecoster,项目名称:NuGet.Analyze,代码行数:20,代码来源:ConfigInterpreter.cs


示例13: FivePackagesSomeDependenciesReturnsCorrectOrder

        public void FivePackagesSomeDependenciesReturnsCorrectOrder()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act  
            string installList = packageDependency.GetInstallListFromDependencies(new string[]
                                    {"Owin: ", "NLog.Config: NLog", "Owin.Identity: Owin", "NLog: ",
                                     "NLog.Web: NLog.Config"});

            // Assert
            Assert.AreEqual(installList, "Owin, Owin.Identity, NLog, NLog.Config, NLog.Web");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:13,代码来源:PackageDependencyTests.cs


示例14: UpgradeAfterAssetsLoaded

 /// <summary>
 /// Performs the second step of package migration, after assets have been loaded.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="log">The log.</param>
 /// <param name="dependentPackage">The source package.</param>
 /// <param name="dependency">The dependency.</param>
 /// <param name="dependencyPackage">The dependency package.</param>
 /// <param name="dependencyVersionBeforeUpdate">The version before the update.</param>
 /// <returns></returns>
 public virtual bool UpgradeAfterAssetsLoaded(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, PackageVersionRange dependencyVersionBeforeUpdate)
 {
     return true;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:14,代码来源:PackageUpgrader.cs


示例15: Upgrade

 /// <summary>
 /// Performs the package migration, before assets are loaded
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="log">The log.</param>
 /// <param name="dependentPackage">The source package.</param>
 /// <param name="dependency">The dependency.</param>
 /// <param name="dependencyPackage">The dependency package.</param>
 /// <param name="assetFiles">The asset files.</param>
 /// <returns></returns>
 public abstract bool Upgrade(PackageSession session, ILogger log, Package dependentPackage, PackageDependency dependency, Package dependencyPackage, IList<PackageLoadingAssetFile> assetFiles);
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:11,代码来源:PackageUpgrader.cs


示例16: FivePackagesNoDependenciesReturnsCorrectOrder

        public void FivePackagesNoDependenciesReturnsCorrectOrder()
        {
            // Arrange
            var packageDependency = new PackageDependency();

            // Act  
            string installList = packageDependency.GetInstallListFromDependencies(new string[]
                                    { "NLog: ", "EntityFramework: ", "AspNet.WebAPI: ", "Owin: ", "Ice: "});

            // Assert
            Assert.AreEqual(installList, "NLog, EntityFramework, AspNet.WebAPI, Owin, Ice");
        }
开发者ID:kds-snyder,项目名称:PackageDependencies,代码行数:12,代码来源:PackageDependencyTests.cs


示例17: ResolveDependency

 protected override IPackage ResolveDependency(PackageDependency dependency)
 {
     return _repository.ResolveDependency(dependency, allowPrereleaseVersions: false, preferListedPackages: false);
 }
开发者ID:atheken,项目名称:nuget,代码行数:4,代码来源:ProjectFactory.cs


示例18: ResolveDependenciesForInstallPackageResolvesDependencyWithConstraintsUsingDependencyResolver

        public void ResolveDependenciesForInstallPackageResolvesDependencyWithConstraintsUsingDependencyResolver()
        {
            // Arrange            
            var packageDependency = new PackageDependency("B", new VersionSpec { MinVersion = new SemanticVersion("1.1") });
            IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
                                                            dependencies: new List<PackageDependency> { packageDependency });
            IPackage packageB12 = PackageUtility.CreatePackage("B", "1.2");
            var repository = new Mock<PackageRepositoryBase>(MockBehavior.Strict);
            repository.Setup(c => c.GetPackages()).Returns(new[] { packageA }.AsQueryable());
            var dependencyProvider = repository.As<IDependencyResolver>();
            dependencyProvider.Setup(c => c.ResolveDependency(packageDependency, It.IsAny<IPackageConstraintProvider>(), false, true, DependencyVersion.Lowest))
                              .Returns(packageB12).Verifiable();
            var localRepository = new MockPackageRepository();

            IPackageOperationResolver resolver = new InstallWalker(localRepository,
                                                             repository.Object,
                                                             NullLogger.Instance,
                                                             ignoreDependencies: false,
                                                             allowPrereleaseVersions: false);


            // Act
            var operations = resolver.ResolveOperations(packageA).ToList();

            // Assert
            Assert.Equal(2, operations.Count);
            Assert.Equal(PackageAction.Install, operations.First().Action);
            Assert.Equal(packageB12, operations.First().Package);
            Assert.Equal(PackageAction.Install, operations.Last().Action);
            Assert.Equal(packageA, operations.Last().Package);

            dependencyProvider.Verify();
        }
开发者ID:Berzeger,项目名称:NuGet,代码行数:33,代码来源:PackageWalkerTest.cs


示例19: UpdatePackageReferenceIncludeDependencyPackageCorrectly2

        public void UpdatePackageReferenceIncludeDependencyPackageCorrectly2()
        {
            // Arrange            
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework", new Version("4.0")));
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            var dependency = new PackageDependency("B", null);
            var dependencySet = CreateDependencySet(".NETFramework, Version=4.0", dependency);
            IPackage packageA = PackageUtility.CreatePackageWithDependencySets("A", "1.0",
                                                             dependencySets: new List<PackageDependencySet> { dependencySet },
                                                             content: new[] { "a.txt" });

            var dependency2 = new PackageDependency("B", null);
            var dependencySet2 = CreateDependencySet(".NETFramework, Version=4.5", dependency2);
            IPackage packageA2 = PackageUtility.CreatePackageWithDependencySets("A", "2.0",
                                                                dependencySets: new List<PackageDependencySet> { dependencySet2 },
                                                                content: new[] { "a2.txt" });

            IPackage packageB = PackageUtility.CreatePackage("B", "1.0", content: new[] { "b.txt" });

            sourceRepository.AddPackage(packageB);
            sourceRepository.AddPackage(packageA);
            sourceRepository.AddPackage(packageA2);

            projectManager.AddPackageReference("A", new SemanticVersion("1.0"));

            Assert.True(projectManager.LocalRepository.Exists("A"));
            Assert.True(projectManager.LocalRepository.Exists("B"));

            // Act
            projectManager.UpdatePackageReference("A");

            // Assert
            Assert.False(projectManager.LocalRepository.Exists("A", new SemanticVersion("1.0")));
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("2.0")));
            Assert.False(projectManager.LocalRepository.Exists("B"));
            Assert.True(projectSystem.FileExists("a2.txt"));
            Assert.False(projectSystem.FileExists("b.txt"));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:40,代码来源:ProjectManagerTest.cs


示例20: AddPackageReferenceDoNotIncludeDependencyPackageIfTargetFrameworkDoesNotMatch

        public void AddPackageReferenceDoNotIncludeDependencyPackageIfTargetFrameworkDoesNotMatch(string dependencyVersion)
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem(new FrameworkName(".NETFramework", new Version("2.0")));
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            var dependency = new PackageDependency("B", null);
            var dependencySet = new PackageDependencySet(
                new FrameworkName(".NETFramework", new Version(dependencyVersion)), 
                new PackageDependency[] {dependency});

            IPackage packageA = PackageUtility.CreatePackage("A", "1.0", content: new[] { "a.txt" });
            Mock.Get(packageA).Setup(p => p.DependencySets).Returns(new [] {dependencySet});

            IPackage packageB = PackageUtility.CreatePackage("B", "1.0", content: new[] { "b.txt" });

            sourceRepository.AddPackage(packageB);
            sourceRepository.AddPackage(packageA);

            // Act
            projectManager.AddPackageReference("A");

            // Assert
            Assert.True(projectManager.LocalRepository.Exists("A"));
            Assert.False(projectManager.LocalRepository.Exists("B"));
            Assert.True(projectSystem.FileExists("a.txt"));
            Assert.False(projectSystem.FileExists("b.txt"));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:29,代码来源:ProjectManagerTest.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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