-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunOnStartupManager.cs
More file actions
33 lines (31 loc) · 1.03 KB
/
RunOnStartupManager.cs
File metadata and controls
33 lines (31 loc) · 1.03 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
using System;
namespace RunOnStartup
{
/// <summary>
/// A utility class to get the platform-specific singleton <see cref="IRunOnStartupManager"/>.
/// </summary>
public static class RunOnStartupManager
{
/// <summary>
/// Returns an instance of a class that implements <see cref="IRunOnStartupManager"/> for the current platform.
/// </summary>
/// <exception cref="PlatformNotSupportedException"/>
public static IRunOnStartupManager Instance => _instance ??= CreateInstance();
private static IRunOnStartupManager? _instance;
private static IRunOnStartupManager CreateInstance()
{
if (OperatingSystem.IsWindows())
{
return new RunOnStartupManagerWindows();
}
else if (OperatingSystem.IsLinux())
{
return new RunOnStartupManagerLinux();
}
else
{
throw new PlatformNotSupportedException();
}
}
}
}