New Fetch Profiles

Added a fetch profile method to the Common Plugin Helper.
This commit is contained in:
Brett Hewitson 2020-07-11 19:23:57 +10:00
parent 0cdd760a48
commit 2df6f0cbaf
4 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,7 @@
using ServerManagerTool.Plugin.Common.Lib;
using System.Collections.Generic;
namespace ServerManagerTool.Plugin.Common.Delegates
{
public delegate IList<Profile> FetchProfilesDelegate();
}

View file

@ -0,0 +1,8 @@
namespace ServerManagerTool.Plugin.Common.Lib
{
public class Profile
{
public string ProfileName { get; set; }
public string InstallationFolder { get; set; }
}
}

View file

@ -1,4 +1,7 @@
using System;
using ServerManagerTool.Plugin.Common.Delegates;
using ServerManagerTool.Plugin.Common.Lib;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
@ -17,6 +20,8 @@ namespace ServerManagerTool.Plugin.Common
private static readonly object _syncLock = new object();
private readonly Object _syncLockProcessAlert = new Object();
private readonly Object _syncLockFetchProfiles = new Object();
private FetchProfilesDelegate _fetchProfilesCallback;
private bool _disposed;
private PluginHelper()
@ -143,6 +148,14 @@ namespace ServerManagerTool.Plugin.Common
File.Delete(pluginFile);
}
internal IList<Profile> FetchProfileList()
{
lock (_syncLockFetchProfiles)
{
return _fetchProfilesCallback?.Invoke() ?? new List<Profile>();
}
}
internal void LoadPlugin(string pluginFile)
{
if (string.IsNullOrWhiteSpace(pluginFile))
@ -251,6 +264,11 @@ namespace ServerManagerTool.Plugin.Common
return true;
}
internal void SetFetchProfileCallback(FetchProfilesDelegate callback)
{
_fetchProfilesCallback = callback;
}
public void Dispose()
{
Dispose(true);
@ -265,6 +283,7 @@ namespace ServerManagerTool.Plugin.Common
if (disposing)
{
_fetchProfilesCallback = null;
_instance = null;
}

View file

@ -37,3 +37,4 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo("ARK Server Manager")]
[assembly: InternalsVisibleTo("ConanServerManager")]
[assembly: InternalsVisibleTo("ServerManager")]
[assembly: InternalsVisibleTo("ServerManager.Plugin.Common.UnitTests")]