forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerConnection.cs
More file actions
41 lines (36 loc) · 1.24 KB
/
Copy pathServerConnection.cs
File metadata and controls
41 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// -----------------------------------------------------------------------------
// <copyright file="ServerConnection.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------
namespace WinGetMCPServer
{
using Microsoft.Management.Deployment;
/// <summary>
/// Maintains the connection to the COM server.
/// </summary>
internal static class ServerConnection
{
private static PackageManager? packageManager = null;
public static PackageManager Instance
{
get
{
if (packageManager == null)
{
packageManager = new PackageManager();
}
try
{
// Perform the simplest available call to check if the COM server is still active.
_ = packageManager.Version;
}
catch
{
packageManager = new PackageManager();
}
return packageManager;
}
}
}
}