aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs122
1 files changed, 13 insertions, 109 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index ff6586ac1..9b9c6146f 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -421,8 +421,6 @@ namespace Emby.Server.Implementations
ImageEncoder = imageEncoder;
- //SetBaseExceptionMessage();
-
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
NetworkManager.NetworkChanged += NetworkManager_NetworkChanged;
@@ -687,18 +685,6 @@ namespace Emby.Server.Implementations
return parts;
}
- // TODO: @bond
- /*
- private void SetBaseExceptionMessage()
- {
- var builder = GetBaseExceptionMessage(ApplicationPaths);
-
- builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine));
- builder.Insert(0, "*** Error Report ***" + Environment.NewLine);
-
- LoggerFactory.ExceptionMessagePrefix = builder.ToString();
- }*/
-
/// <summary>
/// Runs the startup tasks.
/// </summary>
@@ -734,8 +720,6 @@ namespace Emby.Server.Implementations
RunEntryPoints(entryPoints, false);
Logger.LogInformation("All entry points have started");
- //LoggerFactory.RemoveConsoleOutput();
-
return Task.CompletedTask;
}
@@ -749,7 +733,7 @@ namespace Emby.Server.Implementations
}
var name = entryPoint.GetType().FullName;
- Logger.LogInformation("Starting entry point {0}", name);
+ Logger.LogInformation("Starting entry point {Name}", name);
var now = DateTime.UtcNow;
try
{
@@ -757,9 +741,9 @@ namespace Emby.Server.Implementations
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error in {name}", name);
+ Logger.LogError(ex, "Error while running entrypoint {Name}", name);
}
- Logger.LogInformation("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos");
+ Logger.LogInformation("Entry point completed: {Name}. Duration: {Duration} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos");
}
}
@@ -966,9 +950,6 @@ namespace Emby.Server.Implementations
DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LoggerFactory.CreateLogger("DeviceManager"), NetworkManager);
RegisterSingleInstance(DeviceManager);
- var newsService = new Emby.Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
- RegisterSingleInstance<INewsService>(newsService);
-
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory.CreateLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);
RegisterSingleInstance(MediaSourceManager);
@@ -1313,7 +1294,6 @@ namespace Emby.Server.Implementations
{
if (!ServerConfigurationManager.Configuration.IsPortAuthorized)
{
- RegisterServerWithAdministratorAccess();
ServerConfigurationManager.Configuration.IsPortAuthorized = true;
ConfigurationManager.SaveConfiguration();
}
@@ -1384,12 +1364,11 @@ namespace Emby.Server.Implementations
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error getting plugin Id from {pluginName}.", plugin.GetType().FullName);
+ Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName);
}
}
- var hasPluginConfiguration = plugin as IHasPluginConfiguration;
- if (hasPluginConfiguration != null)
+ if (plugin is IHasPluginConfiguration hasPluginConfiguration)
{
hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s));
}
@@ -1808,13 +1787,13 @@ namespace Emby.Server.Implementations
{
var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);
- Logger.LogInformation("File {0} has version {1}", path, result);
+ Logger.LogInformation("File {Path} has version {Version}", path, result);
return result;
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error getting version number from {path}", path);
+ Logger.LogError(ex, "Error getting version number from {Path}", path);
return new Version(1, 0);
}
@@ -2228,32 +2207,6 @@ namespace Emby.Server.Implementations
protected abstract void ShutdownInternal();
- /// <summary>
- /// Registers the server with administrator access.
- /// </summary>
- private void RegisterServerWithAdministratorAccess()
- {
- Logger.LogInformation("Requesting administrative access to authorize http server");
-
- try
- {
- AuthorizeServer();
- }
- catch (NotImplementedException)
- {
-
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error authorizing server");
- }
- }
-
- protected virtual void AuthorizeServer()
- {
- throw new NotImplementedException();
- }
-
public event EventHandler HasUpdateAvailableChanged;
private bool _hasUpdateAvailable;
@@ -2268,7 +2221,7 @@ namespace Emby.Server.Implementations
if (fireEvent)
{
- EventHelper.FireEventIfNotNull(HasUpdateAvailableChanged, this, EventArgs.Empty, Logger);
+ HasUpdateAvailableChanged?.Invoke(this, EventArgs.Empty);
}
}
}
@@ -2384,11 +2337,10 @@ namespace Emby.Server.Implementations
{
Logger.LogInformation("Application has been updated to version {0}", package.versionStr);
- EventHelper.FireEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs<PackageVersionInfo>
+ ApplicationUpdated?.Invoke(this, new GenericEventArgs<PackageVersionInfo>
{
Argument = package
-
- }, Logger);
+ });
NotifyPendingRestart();
}
@@ -2417,15 +2369,14 @@ namespace Emby.Server.Implementations
{
var type = GetType();
- //LoggerFactory.AddConsoleOutput();
- Logger.LogInformation("Disposing " + type.Name);
+ Logger.LogInformation("Disposing {Type}", type.Name);
var parts = DisposableParts.Distinct().Where(i => i.GetType() != type).ToList();
DisposableParts.Clear();
foreach (var part in parts)
{
- Logger.LogInformation("Disposing " + part.GetType().Name);
+ Logger.LogInformation("Disposing {Type}", part.GetType().Name);
try
{
@@ -2433,58 +2384,11 @@ namespace Emby.Server.Implementations
}
catch (Exception ex)
{
- Logger.LogError(ex, "Error disposing {0}", part.GetType().Name);
+ Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name);
}
}
}
}
-
- private Dictionary<string, string> _values;
- public string GetValue(string name)
- {
- if (_values == null)
- {
- _values = LoadValues();
- }
-
- string value;
-
- if (_values.TryGetValue(name, out value))
- {
- return value;
- }
-
- return null;
- }
-
- // TODO: @bond Remove?
- private Dictionary<string, string> LoadValues()
- {
- Dictionary<string, string> values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
-
- using (var stream = typeof(ApplicationHost).Assembly.GetManifestResourceStream(typeof(ApplicationHost).Namespace + ".values.txt"))
- {
- using (var reader = new StreamReader(stream))
- {
- while (!reader.EndOfStream)
- {
- var line = reader.ReadLine();
- if (string.IsNullOrEmpty(line))
- {
- continue;
- }
-
- var index = line.IndexOf('=');
- if (index != -1)
- {
- values[line.Substring(0, index)] = line.Substring(index + 1);
- }
- }
- }
- }
-
- return values;
- }
}
internal class CertificateInfo