-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured a bit. Added interfaces to a few of the classes.
- Loading branch information
1 parent
aab3f41
commit 3538ae5
Showing
22 changed files
with
202 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
8 changes: 5 additions & 3 deletions
8
src/SRTPluginBase/MainHostEntry.cs → ...uginBase/Implementations/MainHostEntry.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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using SRTPluginBase.Interfaces; | ||
|
||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public class MainHostEntry | ||
public class MainHostEntry : IMainHostEntry | ||
{ | ||
public string Name { get; set; } | ||
public string DisplayName { get; set; } | ||
public string Description { get; set; } | ||
public Uri RepoURL { get; set; } | ||
public Uri ManifestURL { get; set; } | ||
|
||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Always)] | ||
public ManifestEntryJson? Manifest { get; private set; } | ||
public async Task SetManifestAsync(HttpClient client) => Manifest = await Helpers.GetSRTJsonAsync<ManifestEntryJson>(client, ManifestURL); | ||
public async Task SetManifestAsync(HttpClient client) => Manifest = await client.GetSRTJsonAsync<ManifestEntryJson>(ManifestURL); | ||
} | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
} |
9 changes: 5 additions & 4 deletions
9
src/SRTPluginBase/MainJson.cs → ...SRTPluginBase/Implementations/MainJson.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using System.Collections.Generic; | ||
using SRTPluginBase.Interfaces; | ||
|
||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public class MainJson | ||
public class MainJson : IMainJson | ||
{ | ||
public IEnumerable<MainHostEntry> Hosts { get; set; } | ||
public IEnumerable<MainPluginEntry> Plugins { get; set; } | ||
public IEnumerable<IMainHostEntry> Hosts { get; set; } | ||
public IEnumerable<IMainPluginEntry> Plugins { get; set; } | ||
} | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
} |
11 changes: 7 additions & 4 deletions
11
src/SRTPluginBase/MainPluginEntry.cs → ...inBase/Implementations/MainPluginEntry.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 |
---|---|---|
@@ -1,24 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
using SRTPluginBase.Interfaces; | ||
|
||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public class MainPluginEntry | ||
public class MainPluginEntry : IMainPluginEntry | ||
{ | ||
public string Name { get; set; } | ||
public string DisplayName { get; set; } | ||
public string Description { get; set; } | ||
public MainPluginPlatformEnum Platform { get; set; } | ||
public MainPluginTypeEnum Type { get; set; } | ||
public IEnumerable<string> Tags { get; set; } | ||
public Uri RepoURL { get; set; } | ||
public Uri ManifestURL { get; set; } | ||
|
||
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Always)] | ||
public async Task SetManifestAsync(HttpClient client) => Manifest = await client.GetSRTJsonAsync<ManifestEntryJson>(ManifestURL); | ||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)] | ||
public ManifestEntryJson? Manifest { get; private set; } | ||
public async Task SetManifestAsync(HttpClient client) => Manifest = await Helpers.GetSRTJsonAsync<ManifestEntryJson>(client, ManifestURL); | ||
} | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
} |
2 changes: 1 addition & 1 deletion
2
src/SRTPluginBase/MainPluginPlatformEnum.cs → ...Implementations/MainPluginPlatformEnum.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
public enum MainPluginPlatformEnum : int | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
src/SRTPluginBase/MainPluginTypeEnum.cs → ...ase/Implementations/MainPluginTypeEnum.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
public enum MainPluginTypeEnum : int | ||
{ | ||
|
7 changes: 4 additions & 3 deletions
7
src/SRTPluginBase/ManifestEntryJson.cs → ...Base/Implementations/ManifestEntryJson.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using System.Collections.Generic; | ||
using SRTPluginBase.Interfaces; | ||
|
||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Implementations | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
public class ManifestEntryJson | ||
public class ManifestEntryJson : IManifestEntryJson | ||
{ | ||
public IEnumerable<string> Contributors { get; set; } | ||
public IEnumerable<ManifestReleaseJson> Releases { get; set; } | ||
public IEnumerable<IManifestReleaseJson> Releases { get; set; } | ||
} | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
} |
5 changes: 3 additions & 2 deletions
5
src/SRTPluginBase/ManifestReleaseJson.cs → ...se/Implementations/ManifestReleaseJson.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
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,58 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using System; | ||
using System.Text.Json.Serialization; | ||
using SRTPluginBase.Implementations; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IMainEntry | ||
{ | ||
#region Serialized Properties | ||
|
||
/// <summary> | ||
/// The unique name for this entry. Must not contain characters not suitable for file and folder paths. | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// The user-friendly display name for this entry. | ||
/// </summary> | ||
public string DisplayName { get; set; } | ||
|
||
/// <summary> | ||
/// A description of what this entry is for. | ||
/// </summary> | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// The URL to this entry's source control repository. | ||
/// </summary> | ||
public Uri RepoURL { get; set; } | ||
|
||
/// <summary> | ||
/// The URL to this entry's manifest json file. | ||
/// </summary> | ||
public Uri ManifestURL { get; set; } | ||
|
||
#endregion | ||
|
||
#region Non-serialized Properties | ||
|
||
/// <summary> | ||
/// The manifest file's contents deserialized from the ManifestURL. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)] | ||
public ManifestEntryJson? Manifest { get; } | ||
|
||
#endregion | ||
|
||
/// <summary> | ||
/// Deserializes the manifest located at the Uri ManifestURL. | ||
/// </summary> | ||
/// <param name="client">An HttpClient instance to use when retrieving the manifest json.</param> | ||
/// <returns>A asynchronous Task instance for this request.</returns> | ||
public abstract Task SetManifestAsync(HttpClient client); | ||
|
||
} | ||
} |
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,6 @@ | ||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IMainHostEntry : IMainEntry | ||
{ | ||
} | ||
} |
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,21 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IMainJson | ||
{ | ||
#region Serialized Properties | ||
|
||
/// <summary> | ||
/// An array of plugin hosts. | ||
/// </summary> | ||
public IEnumerable<IMainHostEntry> Hosts { get; set; } | ||
|
||
/// <summary> | ||
/// An array of plugins. | ||
/// </summary> | ||
public IEnumerable<IMainPluginEntry> Plugins { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
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,27 @@ | ||
using System.Collections.Generic; | ||
using SRTPluginBase.Implementations; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IMainPluginEntry : IMainEntry | ||
{ | ||
#region Serialized Properties | ||
|
||
/// <summary> | ||
/// A enumeration value indicating what platform architecture this plugin targets. | ||
/// </summary> | ||
public MainPluginPlatformEnum Platform { get; set; } | ||
|
||
/// <summary> | ||
/// A enumeration value indicating which type of plugin this is. | ||
/// </summary> | ||
public MainPluginTypeEnum Type { get; set; } | ||
|
||
/// <summary> | ||
/// A list of tags to assist in filtering and sorting. Examples for a DirectX Consumer plugin might include { "Consumer", "UI", "Overlay", "DirectX" }. | ||
/// </summary> | ||
public IEnumerable<string> Tags { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
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,21 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IManifestEntryJson | ||
{ | ||
#region Serialized Properties | ||
|
||
/// <summary> | ||
/// The contributors to this entry. | ||
/// </summary> | ||
public IEnumerable<string> Contributors { get; set; } | ||
|
||
/// <summary> | ||
/// An array of releases for this entry. | ||
/// </summary> | ||
public IEnumerable<IManifestReleaseJson> Releases { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
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,21 @@ | ||
using System; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IManifestReleaseJson | ||
{ | ||
#region Serialized Properties | ||
|
||
/// <summary> | ||
/// The version of this entry. | ||
/// </summary> | ||
public string Version { get; set; } | ||
|
||
/// <summary> | ||
/// The download Uri for this version of the entry. | ||
/// </summary> | ||
public Uri DownloadURL { get; set; } | ||
|
||
#endregion | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/SRTPluginBase/IPluginConfiguration.cs → ...inBase/Interfaces/IPluginConfiguration.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace SRTPluginBase | ||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IPluginConfiguration | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
src/SRTPluginBase/IPluginConsumer.cs → ...TPluginBase/Interfaces/IPluginConsumer.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
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,15 @@ | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace SRTPluginBase.Interfaces | ||
{ | ||
public interface IPluginHost : IHostedService | ||
{ | ||
/// <summary> | ||
/// Retrieves a loaded plugin by name. | ||
/// </summary> | ||
/// <typeparam name="T">The type of plugin to retrieve.</typeparam> | ||
/// <param name="pluginName">The plugin's name.</param> | ||
/// <returns>The requested plugin, or null if not loaded.</returns> | ||
T? GetPluginReference<T>(string pluginName) where T : class, IPlugin; | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
src/SRTPluginBase/IPluginInfo.cs → src/SRTPluginBase/Interfaces/IPluginInfo.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
2 changes: 1 addition & 1 deletion
2
src/SRTPluginBase/IPluginProducer.cs → ...TPluginBase/Interfaces/IPluginProducer.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
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