當前位置: 首頁>>代碼示例>>C#>>正文


C# Package.ApplyEdit方法代碼示例

本文整理匯總了C#中NuGetGallery.Package.ApplyEdit方法的典型用法代碼示例。如果您正苦於以下問題:C# Package.ApplyEdit方法的具體用法?C# Package.ApplyEdit怎麽用?C# Package.ApplyEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NuGetGallery.Package的用法示例。


在下文中一共展示了Package.ApplyEdit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ApplyPackageEditUpdatesPackage

            public void ApplyPackageEditUpdatesPackage()
            {
                var p = new Package
                {
                    Title = "OldTitle",
                    Description = "OldDescription",
                    Summary = "OldSummary",
                    Tags = "OldTags",
                    FlattenedAuthors = "OldAuthors",
                    Copyright = "OldCopyright",
                    ReleaseNotes = "OldReleaseNotes",
                    Hash = "OldHash",
                    HashAlgorithm = "SHA512",
                    PackageFileSize = 0,
                };

                var pe = new PackageEdit
                {
                    Title = "NewTitle",
                    Description = "NewDescription",
                    Summary = "NewSummary",
                    Tags = "NewTags",
                    Authors = "NewAuthors",
                    Copyright = "NewCopyright",
                    ReleaseNotes = "NewReleaseNotes",
                };

                p.PackageEdits.Add(pe);
                p.ApplyEdit(pe, "SHA1024", "NewHash", 1);

                Assert.Equal(1, p.PackageHistories.Count);
                var h = p.PackageHistories.ElementAt(0);
                Assert.Equal("OldTitle", h.Title);
                Assert.Equal("OldDescription", h.Description);
                Assert.Equal("OldSummary", h.Summary);
                Assert.Equal("OldTags", h.Tags);
                Assert.Equal("OldAuthors", h.Authors);
                Assert.Equal("OldCopyright", h.Copyright);
                Assert.Equal("OldReleaseNotes", h.ReleaseNotes);
                Assert.Equal("SHA512", h.HashAlgorithm);
                Assert.Equal("OldHash", h.Hash);
                Assert.Equal(0, h.PackageFileSize);

                Assert.Equal("NewTitle", p.Title);
                Assert.Equal("NewDescription", p.Description);
                Assert.Equal("NewSummary", p.Summary);
                Assert.Equal("NewTags", p.Tags);
                Assert.Equal("NewAuthors", p.FlattenedAuthors);
                Assert.Equal("NewCopyright", p.Copyright);
                Assert.Equal("NewReleaseNotes", p.ReleaseNotes);
                Assert.Equal("SHA1024", p.HashAlgorithm);
                Assert.Equal("NewHash", p.Hash);
                Assert.Equal(1, p.PackageFileSize);

                Assert.Equal(1, p.PackageEdits.Count); // It has to be deleted from the ObjectContext anyway so no point trying to delete it as part of ApplyEdit.
            }
開發者ID:henrycomein,項目名稱:NuGetGallery,代碼行數:56,代碼來源:PackageFacts.cs


注:本文中的NuGetGallery.Package.ApplyEdit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。