From d207d9448bd711559ee9c9a47b414c4516bb7e2f Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Wed, 28 Feb 2018 19:25:47 +0000 Subject: [PATCH] create IDocumentPathProvider to allow flexibility for exporting. Improve Export interface for IExportManager and IFileExporter to prevent leaky abstraction Add comments (INotifierProvider, IPluginInformation, IPluginDetails) Create IProviderConfiguration for configuration settings of plugins in future. Create Factory and Interface for IRaceStartController components, in order to control how the race starts. Create Race Objects (RaceLap, RaceSessionHistory) --- .../Interfaces/IDocumentPathProvider.cs | 7 ++++ RaceLapTimer/Interfaces/IExportManager.cs | 2 +- RaceLapTimer/Interfaces/IFileExporter.cs | 2 +- RaceLapTimer/Interfaces/INotifierProvider.cs | 21 +++++++++-- RaceLapTimer/Interfaces/IPluginInformation.cs | 4 +++ .../Interfaces/IProviderConfiguration.cs | 29 +++++++++++++++ .../Interfaces/IRaceStartController.cs | 7 ++++ .../Interfaces/IRaceStartControllerFactory.cs | 7 ++++ RaceLapTimer/Interfaces/Interfaces.csproj | 7 ++++ RaceLapTimer/Interfaces/PluginDetails.cs | 20 ++++++++++- RaceLapTimer/Interfaces/RaceLap.cs | 10 ++++++ RaceLapTimer/Interfaces/RaceSessionHistory.cs | 35 +++++++++++++++++++ RaceLapTimer/Interfaces/StartRaceDelegate.cs | 4 +++ 13 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 RaceLapTimer/Interfaces/IDocumentPathProvider.cs create mode 100644 RaceLapTimer/Interfaces/IProviderConfiguration.cs create mode 100644 RaceLapTimer/Interfaces/IRaceStartController.cs create mode 100644 RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs create mode 100644 RaceLapTimer/Interfaces/RaceLap.cs create mode 100644 RaceLapTimer/Interfaces/RaceSessionHistory.cs create mode 100644 RaceLapTimer/Interfaces/StartRaceDelegate.cs diff --git a/RaceLapTimer/Interfaces/IDocumentPathProvider.cs b/RaceLapTimer/Interfaces/IDocumentPathProvider.cs new file mode 100644 index 0000000..a3b0e00 --- /dev/null +++ b/RaceLapTimer/Interfaces/IDocumentPathProvider.cs @@ -0,0 +1,7 @@ +namespace Interfaces +{ + public interface IDocumentPathProvider + { + string GetPath(); + } +} \ No newline at end of file diff --git a/RaceLapTimer/Interfaces/IExportManager.cs b/RaceLapTimer/Interfaces/IExportManager.cs index 1a0f8d7..624b7cf 100644 --- a/RaceLapTimer/Interfaces/IExportManager.cs +++ b/RaceLapTimer/Interfaces/IExportManager.cs @@ -7,7 +7,7 @@ namespace Interfaces { List GetExporters(); - Stream Export(string fileContent, string baseUrl); + void Export(string exportType, string fileContent, string baseUrl, out Stream exportStream); List GetExporterDetails(); } diff --git a/RaceLapTimer/Interfaces/IFileExporter.cs b/RaceLapTimer/Interfaces/IFileExporter.cs index 8b017ae..0ccc59d 100644 --- a/RaceLapTimer/Interfaces/IFileExporter.cs +++ b/RaceLapTimer/Interfaces/IFileExporter.cs @@ -4,7 +4,7 @@ namespace Interfaces { public interface IFileExporter { - Stream Export(string fileContent, string baseUrl); + void Export(string fileContent, string baseUrl, out Stream exportStream); ExportProviderDetails GetDetails(); } diff --git a/RaceLapTimer/Interfaces/INotifierProvider.cs b/RaceLapTimer/Interfaces/INotifierProvider.cs index b58ad8a..bd12046 100644 --- a/RaceLapTimer/Interfaces/INotifierProvider.cs +++ b/RaceLapTimer/Interfaces/INotifierProvider.cs @@ -3,14 +3,29 @@ public interface INotifierProvider : IPluginInformation { string GetDisplayName(); + /// + /// Raise a notification that the race has started. + /// + /// Race details void NotifyRaceStarted(NotificationEventArgs args); + /// + /// Raise a notification to indicate that a race will be starting soon. + /// + /// Race details void NotifyRaceStarting(NotificationEventArgs args); + /// + /// Raise a notification that a racer has completed a lap of the track. + /// + /// Race details + /// The pilot that has just completed a lap. void NotifyRaceLapEvent(NotificationEventArgs args, Pilot pilot); + /// + /// Raise a notification when the race is won and completed. + /// + /// + /// void NotifyRaceWinner(NotificationEventArgs args, Pilot pilot); void NotifyRaceFinished(NotificationEventArgs args); - - //Dictionary NotifierConfigurationSettings { get; } - //Dictionary> ParseConfiguration(Dictionary properties); } public class ValidationError diff --git a/RaceLapTimer/Interfaces/IPluginInformation.cs b/RaceLapTimer/Interfaces/IPluginInformation.cs index 19c708a..7585283 100644 --- a/RaceLapTimer/Interfaces/IPluginInformation.cs +++ b/RaceLapTimer/Interfaces/IPluginInformation.cs @@ -2,6 +2,10 @@ { public interface IPluginInformation { + /// + /// Get details of the plugin. + /// + /// Returns object of giving the details of the plugin. PluginDetails GetPluginDetails(); } } diff --git a/RaceLapTimer/Interfaces/IProviderConfiguration.cs b/RaceLapTimer/Interfaces/IProviderConfiguration.cs new file mode 100644 index 0000000..4e6270d --- /dev/null +++ b/RaceLapTimer/Interfaces/IProviderConfiguration.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; + +namespace Interfaces +{ + public interface IProviderConfiguration + { + /// + /// Get a Key value pair of configuration settings + /// + /// + /// Key: Port Number + /// Value: 1111 + /// + Dictionary ConfigurationSettings { get; } + + /// + /// Parse the given configuration settings and validate the given values. + /// + /// Key value pairs of configuration settings + /// A Dictionary containing a list of validation errors for each configuration setting (Key). + Dictionary> ValidateConfigurations(Dictionary configurations); + + /// + /// Set/update the configuration settings. + /// + /// Dictionary of key value pairs detailing the configuration settings. + void SetConfigurations(Dictionary configurations); + } +} diff --git a/RaceLapTimer/Interfaces/IRaceStartController.cs b/RaceLapTimer/Interfaces/IRaceStartController.cs new file mode 100644 index 0000000..ec30080 --- /dev/null +++ b/RaceLapTimer/Interfaces/IRaceStartController.cs @@ -0,0 +1,7 @@ +namespace Interfaces +{ + public interface IRaceStartController + { + event StartRaceDelegate StartRace; + } +} \ No newline at end of file diff --git a/RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs b/RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs new file mode 100644 index 0000000..a2496ca --- /dev/null +++ b/RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs @@ -0,0 +1,7 @@ +namespace Interfaces +{ + public interface IRaceStartControllerFactory + { + IRaceStartController GetProvider(); + } +} diff --git a/RaceLapTimer/Interfaces/Interfaces.csproj b/RaceLapTimer/Interfaces/Interfaces.csproj index 07646dd..9f6856e 100644 --- a/RaceLapTimer/Interfaces/Interfaces.csproj +++ b/RaceLapTimer/Interfaces/Interfaces.csproj @@ -44,6 +44,7 @@ + @@ -55,6 +56,9 @@ + + + @@ -64,11 +68,14 @@ + + + diff --git a/RaceLapTimer/Interfaces/PluginDetails.cs b/RaceLapTimer/Interfaces/PluginDetails.cs index dac62db..a2b9a82 100644 --- a/RaceLapTimer/Interfaces/PluginDetails.cs +++ b/RaceLapTimer/Interfaces/PluginDetails.cs @@ -2,16 +2,34 @@ { public class PluginDetails { - public PluginDetails(string pluginName, string pluginAuthor, string pluginDescription, string pluginVersion) + public PluginDetails(string pluginName, string pluginAuthor, string pluginDescription, string pluginVersion, string pluginDisplayName) { PluginName = pluginName; PluginAuthor = pluginAuthor; PluginDescription = pluginDescription; PluginVersion = pluginVersion; + PluginDisplayName = pluginDisplayName; } + + /// + /// The name of the plugin + /// public string PluginName { get; } + /// + /// The author of the plugin (can be a company/organisation). + /// public string PluginAuthor { get; } + /// + /// Description of the plugins purpose/what it is designed to achieve. + /// public string PluginDescription { get; } + /// + /// The version of the plugin (can be used for semantic versioning). + /// public string PluginVersion { get; } + /// + /// The display name of the plugin to be used in any administration/information pages + /// + public string PluginDisplayName { get; } } } diff --git a/RaceLapTimer/Interfaces/RaceLap.cs b/RaceLapTimer/Interfaces/RaceLap.cs new file mode 100644 index 0000000..7f47eb1 --- /dev/null +++ b/RaceLapTimer/Interfaces/RaceLap.cs @@ -0,0 +1,10 @@ +namespace Interfaces +{ + public class RaceLap + { + public Pilot RacerDetails { get; set; } + public int LapNumber { get; set; } + public int LapTimeMs { get; set; } + public int OverallPositon { get; set; } + } +} \ No newline at end of file diff --git a/RaceLapTimer/Interfaces/RaceSessionHistory.cs b/RaceLapTimer/Interfaces/RaceSessionHistory.cs new file mode 100644 index 0000000..462644b --- /dev/null +++ b/RaceLapTimer/Interfaces/RaceSessionHistory.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace Interfaces +{ + public class RaceSessionHistory + { + public RaceSessionHistory() + { + LapTimes = new List(); + Racers = new List(); + } + + public string Title { get; set; } + + public int LapCount { get; set; } + + public int RacerCount { get; set; } + + public string RaceType + { + get { return Enum.GetName(typeof(RaceMode), RaceMode); } + } + + public RaceMode RaceMode { get; set; } + + public Pilot FastestPilot { get; set; } + + public int FastestLapTime { get; set; } + + public List LapTimes { get; set; } + + public List Racers { get; set; } + } +} \ No newline at end of file diff --git a/RaceLapTimer/Interfaces/StartRaceDelegate.cs b/RaceLapTimer/Interfaces/StartRaceDelegate.cs new file mode 100644 index 0000000..7e2b467 --- /dev/null +++ b/RaceLapTimer/Interfaces/StartRaceDelegate.cs @@ -0,0 +1,4 @@ +namespace Interfaces +{ + public delegate void StartRaceDelegate(PluginDetails sender); +} \ No newline at end of file