Create IRequiresRegistration. First part of #31

pull/702/head
Eric Reed 12 years ago
parent 133047a495
commit d3b37a73cc

@ -226,6 +226,8 @@ namespace MediaBrowser.Common.Implementations
Task.Run(() => ConfigureAutoRunAtStartup());
Task.Run(() => SecurityManager.LoadAllRegistrationInfo());
ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated;
});
}

@ -1,4 +1,5 @@
using MediaBrowser.Common.Configuration;
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Security;
using MediaBrowser.Model.Serialization;
using Mediabrowser.Model.Entities;
@ -7,6 +8,7 @@ using MediaBrowser.Common.Net;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
namespace MediaBrowser.Common.Implementations.Security
{
@ -44,6 +46,7 @@ namespace MediaBrowser.Common.Implementations.Security
private IHttpClient _httpClient;
private IJsonSerializer _jsonSerializer;
private IApplicationHost _appHost;
private IEnumerable<IRequiresRegistration> _registeredEntities;
/// <summary>
/// Initializes a new instance of the <see cref="PluginSecurityManager" /> class.
@ -58,9 +61,23 @@ namespace MediaBrowser.Common.Implementations.Security
_appHost = appHost;
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_registeredEntities = _appHost.GetExports<IRequiresRegistration>();
MBRegistration.Init(appPaths);
}
/// <summary>
/// Load all registration info for all entities that require registration
/// </summary>
/// <returns></returns>
public async Task LoadAllRegistrationInfo()
{
var tasks = new List<Task>();
tasks.AddRange(_registeredEntities.Select(i => i.LoadRegistrationInfoAsync()));
await Task.WhenAll(tasks);
ResetSupporterInfo();
}
/// <summary>
/// Gets the registration status.
/// </summary>

@ -100,6 +100,7 @@
<Compile Include="ScheduledTasks\IntervalTrigger.cs" />
<Compile Include="ScheduledTasks\TaskCompletionEventArgs.cs" />
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
<Compile Include="Security\IRequiresRegistration.cs" />
<Compile Include="Security\ISecurityManager.cs" />
<Compile Include="Updates\IPackageManager.cs" />
</ItemGroup>

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace MediaBrowser.Common.Security
{
public interface IRequiresRegistration
{
Task LoadRegistrationInfoAsync();
}
}

@ -30,5 +30,11 @@ namespace MediaBrowser.Common.Security
/// <param name="mb2Equivalent">The MB2 equivalent.</param>
/// <returns>Task{MBRegistrationRecord}.</returns>
Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null);
/// <summary>
/// Load all registration info for all entities that require registration
/// </summary>
/// <returns></returns>
Task LoadAllRegistrationInfo();
}
}
Loading…
Cancel
Save