-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid recreating IMarkdownPreview control (#6153)
* Avoid recreating markdown control * Remove MarkdownPreview depdency property * Pass IMarkdownPreview into the viewmodel instead of building it there * Add missing using statement * fix merge * Move to singleton * Remove creating instance in tab control * pr comment
- Loading branch information
Showing
8 changed files
with
68 additions
and
40 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/NuGet.Clients/NuGet.PackageManagement.UI/Utility/MarkdownPreviewSingleton.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.VisualStudio.Markdown.Platform; | ||
|
||
namespace NuGet.PackageManagement.UI | ||
{ | ||
public class MarkdownPreviewSingleton | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
private static IMarkdownPreview Instance; | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
|
||
#pragma warning disable CS0618 // Type or member is obsolete | ||
public static IMarkdownPreview GetInstance() | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
{ | ||
if (Instance == null) | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
Instance = new PreviewBuilder().Build(); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
} | ||
|
||
return Instance; | ||
} | ||
|
||
public static void ResetInstance() | ||
{ | ||
if (Instance != null) | ||
{ | ||
Instance.Dispose(); | ||
Instance = null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters