公司新聞

對 .NET 升級助手的第三方 API 和套件映射支援

發佈 2024年7月1日
分享:

.NET 升級助手

如果您曾經需要將應用程序更新到較新版本的 .NET,您可能會熟悉 .NET 升級助手。這款來自微軟的強大工具使升級項目的過程變得簡單明了 - 至少對於微軟的庫和框架來說是這樣的。對於外部服務,更新到新版本仍然是一個手動且耗時的過程。

好吧,不再是了! .NET 升級助理本身進行了一次重大升級。上個月,微軟宣佈其工具將支援第三方API和套件映射,允許開發人員分享自己的映射,並使用戶在更新到新框架時更容易替換過時的第三方API和套件。

新增的第三方API支援提供了一種標準化的API整合方法,而套件映射則如其所言 - 它映射了應用程式中使用的所有套件,簡化了更新依賴項並改善了專案的整體穩定性。

更換程式庫從未如此簡單

在此更新之前,如果您的應用程式依賴於外部服務,升級到較新的 .NET 版本或更改框架都非常困難。這意味著需要手動找到等效的 API 和套件——而這還不包括更新所有程式碼中的類型和方法。如同微軟在其公告中所解釋的那樣:

以 Xamarin.Forms.Color 為例。不僅需要將命名空間從 Xamarin.Forms 更新到 Microsoft.Maui.Graphics,還需要將屬性如 R、G 或 B 更改為 Red、Green 或 Blue,靜態的 Color 屬性如 AliceBlue 現在屬於一個名為 Colors 的新類型。

現在,開發者可以像微軟對自有程式庫那樣創建自己的對映,這些麻煩已成為過去。不僅僅是為了更新程式庫,.NET 升級助手現在還可以用來全面更換程式庫。

將 Iron Software 的產品整合到您的應用程式中一直很簡單,但從另一個程式庫切換到 Iron Software 並不那麼直觀。但是現在,有了自定義的對映和 API 支持,升級您的應用程式到全新的程式庫比以往更容易。我們來看看這段代碼,來用 IronPDF 和 PDFsharp 創建一個簡單的 PDF:

IronPDF

using IronPdf;
var htmlToPdf = new HtmlToPdf();
var pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>");
pdf.SaveAs("ironpdf_example.pdf");
using IronPdf;
var htmlToPdf = new HtmlToPdf();
var pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>");
pdf.SaveAs("ironpdf_example.pdf");
Imports IronPdf
Private htmlToPdf = New HtmlToPdf()
Private pdf = htmlToPdf.RenderHtmlAsPdf("<html><body><h1>Hello, IronPDF!</h1></body></html>")
pdf.SaveAs("ironpdf_example.pdf")
VB   C#

PDFsharp

using PdfSharp.Pdf;
class Program
{
   static void Main()
   {
       // Create a new PDF document
       PdfDocument document = new PdfDocument();
       // Add a page to the document
       PdfPage page = document.AddPage();
       // Obtain a graphics object to draw on the page
       XGraphics gfx = XGraphics.FromPdfPage(page);
       // Draw "Hello, PDFsharp!" on the page
       gfx.DrawString("Hello, PDFsharp!", new XFont("Arial", 12), XBrushes.Black,
           new XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft);
       // Save the document to a file
       document.Save("output.pdf");
       // Close the document
       document.Close();
   }
}
using PdfSharp.Pdf;
class Program
{
   static void Main()
   {
       // Create a new PDF document
       PdfDocument document = new PdfDocument();
       // Add a page to the document
       PdfPage page = document.AddPage();
       // Obtain a graphics object to draw on the page
       XGraphics gfx = XGraphics.FromPdfPage(page);
       // Draw "Hello, PDFsharp!" on the page
       gfx.DrawString("Hello, PDFsharp!", new XFont("Arial", 12), XBrushes.Black,
           new XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft);
       // Save the document to a file
       document.Save("output.pdf");
       // Close the document
       document.Close();
   }
}
Imports PdfSharp.Pdf
Friend Class Program
   Shared Sub Main()
	   ' Create a new PDF document
	   Dim document As New PdfDocument()
	   ' Add a page to the document
	   Dim page As PdfPage = document.AddPage()
	   ' Obtain a graphics object to draw on the page
	   Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
	   ' Draw "Hello, PDFsharp!" on the page
	   gfx.DrawString("Hello, PDFsharp!", New XFont("Arial", 12), XBrushes.Black, New XRect(10, 10, page.Width, page.Height), XStringFormats.TopLeft)
	   ' Save the document to a file
	   document.Save("output.pdf")
	   ' Close the document
	   document.Close()
   End Sub
End Class
VB   C#

如您所見,更換庫可能需要對代碼進行大量更改,這需要很多時間和精力,並可能使您的應用程序變得不穩定。但現在,我們可以半自動化命名空間、類型和方法的更改,讓您可以輕鬆升級您的項目。

Iron Software 和 .NET相輔相成

隨著 .NET 更新助理這次的更新,它使第三方開發人員能夠保持在技術的最前沿 - 能夠與 .NET Core 和其他框架的最新版本同步更新他們的應用程式。在 Iron Software,我們的產品一直以兼容性為優先。憑藉對多年來各版本 .NET Core、Standard 和 Framework 的支持,我們一直提供業界領先的軟體,無論我們的客戶使用什麼設置。但現在,您可以在不妥協穩定性或功能性的情況下將您的應用程式升級到更新版本 - 我們會一直在您的身邊。

我們對這次 .NET 更新助理的更新感到非常興奮。如果您是對使用此工具來更新受 Iron Software 支持的應用程式的開發人員,請聯繫我們,我們將竭誠幫助。! 對於其他人,敬請期待將改善你的工作流程和項目的套件地圖。

Iron Software 的產品終身授權費用低至 749 美元。 (包括一年的免費支持,因此我們可以幫助您使用這些新工具更新您的應用程序。)您可以從我們的 30 天免費試用開始,我們的軟體在開發過程中也是完全免費使用的,所以您可以真正了解它的功能。為了節省更多費用,請查看 Iron Suite,您可以以兩個工具的價格獲得所有九個 Iron Software 工具。祝您編寫程式愉快。!

< 上一頁
超越代碼:IronPDF為您的業務帶來的優勢
下一個 >
介紹IronWord:用於Word檔編輯的C# DOCX庫