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)
This commit is contained in:
parent
857150ad28
commit
d207d9448b
7
RaceLapTimer/Interfaces/IDocumentPathProvider.cs
Normal file
7
RaceLapTimer/Interfaces/IDocumentPathProvider.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public interface IDocumentPathProvider
|
||||
{
|
||||
string GetPath();
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ namespace Interfaces
|
||||
{
|
||||
List<IFileExporter> GetExporters();
|
||||
|
||||
Stream Export(string fileContent, string baseUrl);
|
||||
void Export(string exportType, string fileContent, string baseUrl, out Stream exportStream);
|
||||
|
||||
List<ExportProviderDetails> GetExporterDetails();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -3,14 +3,29 @@
|
||||
public interface INotifierProvider : IPluginInformation
|
||||
{
|
||||
string GetDisplayName();
|
||||
/// <summary>
|
||||
/// Raise a notification that the race has started.
|
||||
/// </summary>
|
||||
/// <param name="args">Race details</param>
|
||||
void NotifyRaceStarted(NotificationEventArgs args);
|
||||
/// <summary>
|
||||
/// Raise a notification to indicate that a race will be starting soon.
|
||||
/// </summary>
|
||||
/// <param name="args">Race details</param>
|
||||
void NotifyRaceStarting(NotificationEventArgs args);
|
||||
/// <summary>
|
||||
/// Raise a notification that a racer has completed a lap of the track.
|
||||
/// </summary>
|
||||
/// <param name="args">Race details</param>
|
||||
/// <param name="pilot">The pilot that has just completed a lap.</param>
|
||||
void NotifyRaceLapEvent(NotificationEventArgs args, Pilot pilot);
|
||||
/// <summary>
|
||||
/// Raise a notification when the race is won and completed.
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <param name="pilot"></param>
|
||||
void NotifyRaceWinner(NotificationEventArgs args, Pilot pilot);
|
||||
void NotifyRaceFinished(NotificationEventArgs args);
|
||||
|
||||
//Dictionary<string, string> NotifierConfigurationSettings { get; }
|
||||
//Dictionary<string, List<ValidationError>> ParseConfiguration(Dictionary<string, string> properties);
|
||||
}
|
||||
|
||||
public class ValidationError
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
{
|
||||
public interface IPluginInformation
|
||||
{
|
||||
/// <summary>
|
||||
/// Get details of the plugin.
|
||||
/// </summary>
|
||||
/// <returns>Returns object of <see cref="PluginDetails"/> giving the details of the plugin.</returns>
|
||||
PluginDetails GetPluginDetails();
|
||||
}
|
||||
}
|
||||
|
||||
29
RaceLapTimer/Interfaces/IProviderConfiguration.cs
Normal file
29
RaceLapTimer/Interfaces/IProviderConfiguration.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public interface IProviderConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a Key value pair of configuration settings
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// Key: Port Number
|
||||
/// Value: 1111
|
||||
/// </example>
|
||||
Dictionary<string, string> ConfigurationSettings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Parse the given configuration settings and validate the given values.
|
||||
/// </summary>
|
||||
/// <param name="configurations">Key value pairs of configuration settings</param>
|
||||
/// <returns>A Dictionary containing a list of validation errors for each configuration setting (Key).</returns>
|
||||
Dictionary<string, List<ValidationError>> ValidateConfigurations(Dictionary<string, string> configurations);
|
||||
|
||||
/// <summary>
|
||||
/// Set/update the configuration settings.
|
||||
/// </summary>
|
||||
/// <param name="configurations">Dictionary of key value pairs detailing the configuration settings.</param>
|
||||
void SetConfigurations(Dictionary<string, string> configurations);
|
||||
}
|
||||
}
|
||||
7
RaceLapTimer/Interfaces/IRaceStartController.cs
Normal file
7
RaceLapTimer/Interfaces/IRaceStartController.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public interface IRaceStartController
|
||||
{
|
||||
event StartRaceDelegate StartRace;
|
||||
}
|
||||
}
|
||||
7
RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs
Normal file
7
RaceLapTimer/Interfaces/IRaceStartControllerFactory.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public interface IRaceStartControllerFactory
|
||||
{
|
||||
IRaceStartController GetProvider();
|
||||
}
|
||||
}
|
||||
@ -44,6 +44,7 @@
|
||||
<Compile Include="IConfigFilePathProvider.cs" />
|
||||
<Compile Include="IContainerHelper.cs" />
|
||||
<Compile Include="IDbProvider.cs" />
|
||||
<Compile Include="IDocumentPathProvider.cs" />
|
||||
<Compile Include="IExportManager.cs" />
|
||||
<Compile Include="ILoggerService.cs" />
|
||||
<Compile Include="IFileExporter.cs" />
|
||||
@ -55,6 +56,9 @@
|
||||
<Compile Include="INotifierManager.cs" />
|
||||
<Compile Include="INotifierProvider.cs" />
|
||||
<Compile Include="INotifierProviderFactory.cs" />
|
||||
<Compile Include="IProviderConfiguration.cs" />
|
||||
<Compile Include="IRaceStartController.cs" />
|
||||
<Compile Include="IRaceStartControllerFactory.cs" />
|
||||
<Compile Include="ISystemControl.cs" />
|
||||
<Compile Include="ISystemControlManager.cs" />
|
||||
<Compile Include="ISystemControlProviderFactory.cs" />
|
||||
@ -64,11 +68,14 @@
|
||||
<Compile Include="NotificationEventArgs.cs" />
|
||||
<Compile Include="Pilot.cs" />
|
||||
<Compile Include="PluginDetails.cs" />
|
||||
<Compile Include="RaceLap.cs" />
|
||||
<Compile Include="RaceSession.cs" />
|
||||
<Compile Include="IUserStorage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RaceMode.cs" />
|
||||
<Compile Include="RaceSessionHistory.cs" />
|
||||
<Compile Include="SatelliteLog.cs" />
|
||||
<Compile Include="StartRaceDelegate.cs" />
|
||||
<Compile Include="User.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plugin
|
||||
/// </summary>
|
||||
public string PluginName { get; }
|
||||
/// <summary>
|
||||
/// The author of the plugin (can be a company/organisation).
|
||||
/// </summary>
|
||||
public string PluginAuthor { get; }
|
||||
/// <summary>
|
||||
/// Description of the plugins purpose/what it is designed to achieve.
|
||||
/// </summary>
|
||||
public string PluginDescription { get; }
|
||||
/// <summary>
|
||||
/// The version of the plugin (can be used for semantic versioning).
|
||||
/// </summary>
|
||||
public string PluginVersion { get; }
|
||||
/// <summary>
|
||||
/// The display name of the plugin to be used in any administration/information pages
|
||||
/// </summary>
|
||||
public string PluginDisplayName { get; }
|
||||
}
|
||||
}
|
||||
|
||||
10
RaceLapTimer/Interfaces/RaceLap.cs
Normal file
10
RaceLapTimer/Interfaces/RaceLap.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
35
RaceLapTimer/Interfaces/RaceSessionHistory.cs
Normal file
35
RaceLapTimer/Interfaces/RaceSessionHistory.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public class RaceSessionHistory
|
||||
{
|
||||
public RaceSessionHistory()
|
||||
{
|
||||
LapTimes = new List<RaceLap>();
|
||||
Racers = new List<Pilot>();
|
||||
}
|
||||
|
||||
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<RaceLap> LapTimes { get; set; }
|
||||
|
||||
public List<Pilot> Racers { get; set; }
|
||||
}
|
||||
}
|
||||
4
RaceLapTimer/Interfaces/StartRaceDelegate.cs
Normal file
4
RaceLapTimer/Interfaces/StartRaceDelegate.cs
Normal file
@ -0,0 +1,4 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public delegate void StartRaceDelegate(PluginDetails sender);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user