add Async method to interface for IPluginLocator
fix async issue causing deadlock. created ProviderDetails stub to give provider details.
This commit is contained in:
parent
14e82f65c3
commit
156722e0eb
@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public interface IPluginLocator
|
||||
{
|
||||
Task<List<T>> LocateAsync<T>();
|
||||
List<T> Locate<T>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
<Compile Include="INotifierProviderFactory.cs" />
|
||||
<Compile Include="NotificationEventArgs.cs" />
|
||||
<Compile Include="Pilot.cs" />
|
||||
<Compile Include="ProviderDetails.cs" />
|
||||
<Compile Include="RaceSession.cs" />
|
||||
<Compile Include="IUserStorage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
16
RaceLapTimer/Interfaces/ProviderDetails.cs
Normal file
16
RaceLapTimer/Interfaces/ProviderDetails.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public class ProviderDetails
|
||||
{
|
||||
public string ProviderName { get; set; }
|
||||
public string ProviderAuthor { get; set; }
|
||||
public string ProviderDescription { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -11,12 +11,16 @@ namespace RaceLapTimer.Extensions.Notifications
|
||||
{
|
||||
class NotificationManager : INotifierManager
|
||||
{
|
||||
private readonly List<INotifierProvider> _providers;
|
||||
public NotificationManager(IPluginPathProvider pluginPath, IContainerHelper helper, IPluginLocator locator)
|
||||
private List<INotifierProvider> _providers;
|
||||
|
||||
public NotificationManager(IPluginLocator locator)
|
||||
{
|
||||
var providerFactories = locator.Locate<INotifierProviderFactory>();
|
||||
|
||||
//var providerFactories = helper.GetAll<INotifierProviderFactory>().ToList();
|
||||
RegisterProviders(locator);
|
||||
}
|
||||
|
||||
private async void RegisterProviders(IPluginLocator locator)
|
||||
{
|
||||
var providerFactories = await locator.LocateAsync<INotifierProviderFactory>();
|
||||
_providers = new List<INotifierProvider>();
|
||||
foreach (var factory in providerFactories)
|
||||
{
|
||||
@ -35,7 +39,6 @@ namespace RaceLapTimer.Extensions.Notifications
|
||||
{
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
//provider.NotifyRaceStarted(args);
|
||||
Task.Factory.StartNew(() => { provider.NotifyRaceStarted(args); });
|
||||
}
|
||||
}
|
||||
@ -90,13 +93,5 @@ namespace RaceLapTimer.Extensions.Notifications
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class DiscoveredPlugin
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public Type PluginType { get; set; }
|
||||
public Type TypeToBindTo { get; set; }
|
||||
public string UniqueName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +20,10 @@ namespace RaceLapTimer.Extensions
|
||||
_pluginPath = pluginPath;
|
||||
}
|
||||
|
||||
//public async List<T> Locate<T>()
|
||||
//{
|
||||
// return await Task.Run(()=> Locate<T>());
|
||||
//}
|
||||
public async Task<List<T>> LocateAsync<T>()
|
||||
{
|
||||
return await Task.Run(() => Locate<T>());
|
||||
}
|
||||
|
||||
public List<T> Locate<T>()
|
||||
{
|
||||
|
||||
@ -90,8 +90,10 @@
|
||||
<Error Condition="!Exists('..\packages\Nancy.Viewengines.Razor.1.4.3\build\Nancy.ViewEngines.Razor.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Nancy.Viewengines.Razor.1.4.3\build\Nancy.ViewEngines.Razor.targets'))" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /B /Y "$(TargetDir)UdpNotifier.dll" "$(TargetDir)Plugins\UdpNotifier.dll"
|
||||
copy /B /Y "$(TargetDir)NLogConfig.xml" "$(TargetDir)Configs\NLogConfig.xml"</PostBuildEvent>
|
||||
<PostBuildEvent>copy /B /Y "$(SolutionDir)UdpNotifier\$(OutDir)UdpNotifier.dll" "$(TargetDir)Plugins\UdpNotifier.dll"
|
||||
copy /B /Y "$(SolutionDir)IrDaemonNotifier\$(OutDir)IrDaemonNotifier.dll" "$(TargetDir)Plugins\IrDaemonNotifier.dll"
|
||||
copy /B /Y "$(TargetDir)NLogConfig.xml" "$(TargetDir)Configs\NLogConfig.xml"
|
||||
copy /B /Y "$(SolutionDir)RaceLapTimer\$(OutDir)Ninject.Extensions.Xml.dll" "$(TargetDir)Ninject.Extensions.Xml.dll"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user