diff options
| author | Techywarrior <techywarrior@gmail.com> | 2013-04-08 13:47:25 -0700 |
|---|---|---|
| committer | Techywarrior <techywarrior@gmail.com> | 2013-04-08 13:47:25 -0700 |
| commit | b1cc7ccaff8073a5d50287f6db6f78bdd1f4835d (patch) | |
| tree | a5d33f354eb51e826d6be7e264e3809ce658b521 /MediaBrowser.Common.Implementations | |
| parent | a771a812daf7fa8a61153af74d153e8ea891d4a6 (diff) | |
| parent | 57f082051d15da7450fe41f293e0131c8320db33 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Common.Implementations')
| -rw-r--r-- | MediaBrowser.Common.Implementations/BaseApplicationHost.cs | 17 | ||||
| -rw-r--r-- | MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs | 48 |
2 files changed, 41 insertions, 24 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 017f69b62..1a2ab4a51 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -171,6 +171,7 @@ namespace MediaBrowser.Common.Implementations Logger = LogManager.GetLogger("App"); LogManager.ReloadLogger(ConfigurationManager.CommonConfiguration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info); + OnLoggerLoaded(); DiscoverTypes(); @@ -183,6 +184,11 @@ namespace MediaBrowser.Common.Implementations await RunStartupTasks().ConfigureAwait(false); } + protected virtual void OnLoggerLoaded() + { + + } + /// <summary> /// Runs the startup tasks. /// </summary> @@ -195,8 +201,6 @@ namespace MediaBrowser.Common.Implementations Task.Run(() => ConfigureAutoRunAtStartup()); - Task.Run(() => SecurityManager.LoadAllRegistrationInfo()); - ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated; }); } @@ -236,11 +240,6 @@ namespace MediaBrowser.Common.Implementations var assemblies = GetComposablePartAssemblies().ToArray(); - foreach (var assembly in assemblies) - { - Logger.Info("Loading {0}", assembly.FullName); - } - AllTypes = assemblies.SelectMany(GetTypes).ToArray(); AllConcreteTypes = AllTypes.Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType).ToArray(); @@ -270,19 +269,15 @@ namespace MediaBrowser.Common.Implementations RegisterSingleInstance(TaskManager); HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger); - RegisterSingleInstance(HttpClient); NetworkManager = new NetworkManager(); - RegisterSingleInstance(NetworkManager); SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths); - RegisterSingleInstance(SecurityManager); PackageManager = new PackageManager(SecurityManager, NetworkManager, HttpClient, ApplicationPaths, JsonSerializer, Logger); - RegisterSingleInstance(PackageManager); }); } diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 6ac4d2d5d..c7c3b3a57 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -20,15 +20,15 @@ namespace MediaBrowser.Common.Implementations.Security /// <summary> /// The _is MB supporter /// </summary> - private bool? _isMBSupporter; + private bool? _isMbSupporter; /// <summary> /// The _is MB supporter initialized /// </summary> - private bool _isMBSupporterInitialized; + private bool _isMbSupporterInitialized; /// <summary> /// The _is MB supporter sync lock /// </summary> - private object _isMBSupporterSyncLock = new object(); + private object _isMbSupporterSyncLock = new object(); /// <summary> /// Gets a value indicating whether this instance is MB supporter. @@ -38,14 +38,15 @@ namespace MediaBrowser.Common.Implementations.Security { get { - LazyInitializer.EnsureInitialized(ref _isMBSupporter, ref _isMBSupporterInitialized, ref _isMBSupporterSyncLock, () => GetRegistrationStatus("MBSupporter").Result.IsRegistered); - return _isMBSupporter.Value; + LazyInitializer.EnsureInitialized(ref _isMbSupporter, ref _isMbSupporterInitialized, ref _isMbSupporterSyncLock, () => GetRegistrationStatus("MBSupporter").Result.IsRegistered); + return _isMbSupporter.Value; } } - private IHttpClient _httpClient; - private IJsonSerializer _jsonSerializer; - private IApplicationHost _appHost; + private readonly IHttpClient _httpClient; + private readonly IJsonSerializer _jsonSerializer; + private readonly IApplicationHost _appHost; + private readonly IApplicationPaths _applciationPaths; private IEnumerable<IRequiresRegistration> _registeredEntities; protected IEnumerable<IRequiresRegistration> RegisteredEntities { @@ -65,10 +66,10 @@ namespace MediaBrowser.Common.Implementations.Security throw new ArgumentNullException("httpClient"); } + _applciationPaths = appPaths; _appHost = appHost; _httpClient = httpClient; _jsonSerializer = jsonSerializer; - MBRegistration.Init(appPaths); } /// <summary> @@ -92,6 +93,9 @@ namespace MediaBrowser.Common.Implementations.Security /// <returns>Task{MBRegistrationRecord}.</returns> public async Task<MBRegistrationRecord> GetRegistrationStatus(string feature, string mb2Equivalent = null) { + // Do this on demend instead of in the constructor to delay the external assembly load + // Todo: Refactor external methods to take app paths as a param + MBRegistration.Init(_applciationPaths); return await MBRegistration.GetRegistrationStatus(_httpClient, _jsonSerializer, feature, mb2Equivalent).ConfigureAwait(false); } @@ -101,9 +105,18 @@ namespace MediaBrowser.Common.Implementations.Security /// <value>The supporter key.</value> public string SupporterKey { - get { return MBRegistration.SupporterKey; } + get + { + // Do this on demend instead of in the constructor to delay the external assembly load + // Todo: Refactor external methods to take app paths as a param + MBRegistration.Init(_applciationPaths); + return MBRegistration.SupporterKey; + } set { + // Do this on demend instead of in the constructor to delay the external assembly load + // Todo: Refactor external methods to take app paths as a param + MBRegistration.Init(_applciationPaths); if (value != MBRegistration.SupporterKey) { MBRegistration.SupporterKey = value; @@ -119,9 +132,18 @@ namespace MediaBrowser.Common.Implementations.Security /// <value>The legacy key.</value> public string LegacyKey { - get { return MBRegistration.LegacyKey; } + get + { + // Do this on demend instead of in the constructor to delay the external assembly load + // Todo: Refactor external methods to take app paths as a param + MBRegistration.Init(_applciationPaths); + return MBRegistration.LegacyKey; + } set { + // Do this on demend instead of in the constructor to delay the external assembly load + // Todo: Refactor external methods to take app paths as a param + MBRegistration.Init(_applciationPaths); if (value != MBRegistration.LegacyKey) { MBRegistration.LegacyKey = value; @@ -136,8 +158,8 @@ namespace MediaBrowser.Common.Implementations.Security /// </summary> private void ResetSupporterInfo() { - _isMBSupporter = null; - _isMBSupporterInitialized = false; + _isMbSupporter = null; + _isMbSupporterInitialized = false; } } } |
