Remove FireEventIfNotNull
It's a pretty useless "helper" class
This commit is contained in:
parent
e4a041b832
commit
391b48614d
|
@ -119,7 +119,7 @@ namespace Emby.Dlna.Ssdp
|
|||
}
|
||||
};
|
||||
|
||||
EventHelper.FireEventIfNotNull(DeviceDiscoveredInternal, this, args, _logger);
|
||||
DeviceDiscoveredInternal?.Invoke(this, args);
|
||||
}
|
||||
|
||||
private void _DeviceLocator_DeviceUnavailable(object sender, DeviceUnavailableEventArgs e)
|
||||
|
@ -139,7 +139,7 @@ namespace Emby.Dlna.Ssdp
|
|||
}
|
||||
};
|
||||
|
||||
EventHelper.FireEventIfNotNull(DeviceLeft, this, args, _logger);
|
||||
DeviceLeft?.Invoke(this, args);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.Activity
|
|||
|
||||
_repo.Create(entry);
|
||||
|
||||
EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs<ActivityLogEntry>(entry), _logger);
|
||||
EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(entry));
|
||||
}
|
||||
|
||||
public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit)
|
||||
|
|
|
@ -283,12 +283,11 @@ namespace Emby.Server.Implementations.AppBase
|
|||
validatingStore.Validate(currentConfiguration, configuration);
|
||||
}
|
||||
|
||||
EventHelper.FireEventIfNotNull(NamedConfigurationUpdating, this, new ConfigurationUpdateEventArgs
|
||||
NamedConfigurationUpdating?.Invoke( this, new ConfigurationUpdateEventArgs
|
||||
{
|
||||
Key = key,
|
||||
NewConfiguration = configuration
|
||||
|
||||
}, Logger);
|
||||
});
|
||||
|
||||
_configurations.AddOrUpdate(key, configuration, (k, v) => configuration);
|
||||
|
||||
|
@ -305,12 +304,11 @@ namespace Emby.Server.Implementations.AppBase
|
|||
|
||||
protected virtual void OnNamedConfigurationUpdated(string key, object configuration)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(NamedConfigurationUpdated, this, new ConfigurationUpdateEventArgs
|
||||
NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs
|
||||
{
|
||||
Key = key,
|
||||
NewConfiguration = configuration
|
||||
|
||||
}, Logger);
|
||||
});
|
||||
}
|
||||
|
||||
public Type GetConfigurationType(string key)
|
||||
|
|
|
@ -2265,7 +2265,7 @@ namespace Emby.Server.Implementations
|
|||
|
||||
if (fireEvent)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(HasUpdateAvailableChanged, this, EventArgs.Empty, Logger);
|
||||
HasUpdateAvailableChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2381,11 +2381,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();
|
||||
}
|
||||
|
|
|
@ -155,12 +155,11 @@ namespace Emby.Server.Implementations.Collections
|
|||
_providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)), RefreshPriority.High);
|
||||
}
|
||||
|
||||
EventHelper.FireEventIfNotNull(CollectionCreated, this, new CollectionCreatedEventArgs
|
||||
CollectionCreated?.Invoke(this, new CollectionCreatedEventArgs
|
||||
{
|
||||
Collection = collection,
|
||||
Options = options
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
@ -230,12 +229,11 @@ namespace Emby.Server.Implementations.Collections
|
|||
|
||||
if (fireEvent)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(ItemsAddedToCollection, this, new CollectionModifiedEventArgs
|
||||
ItemsAddedToCollection?.Invoke(this, new CollectionModifiedEventArgs
|
||||
{
|
||||
Collection = collection,
|
||||
ItemsChanged = itemList
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,12 +286,11 @@ namespace Emby.Server.Implementations.Collections
|
|||
ForceSave = true
|
||||
}, RefreshPriority.High);
|
||||
|
||||
EventHelper.FireEventIfNotNull(ItemsRemovedFromCollection, this, new CollectionModifiedEventArgs
|
||||
ItemsRemovedFromCollection?.Invoke(this, new CollectionModifiedEventArgs
|
||||
{
|
||||
Collection = collection,
|
||||
ItemsChanged = itemList
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user)
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace Emby.Server.Implementations.Configuration
|
|||
ValidateMetadataPath(newConfig);
|
||||
ValidateSslCertificate(newConfig);
|
||||
|
||||
EventHelper.FireEventIfNotNull(ConfigurationUpdating, this, new GenericEventArgs<ServerConfiguration> { Argument = newConfig }, Logger);
|
||||
ConfigurationUpdating?.Invoke(this, new GenericEventArgs<ServerConfiguration> { Argument = newConfig });
|
||||
|
||||
base.ReplaceConfiguration(newConfiguration);
|
||||
}
|
||||
|
|
|
@ -254,14 +254,14 @@ namespace Emby.Server.Implementations.Devices
|
|||
|
||||
if (CameraImageUploaded != null)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(CameraImageUploaded, this, new GenericEventArgs<CameraImageUploadInfo>
|
||||
CameraImageUploaded?.Invoke(this, new GenericEventArgs<CameraImageUploadInfo>
|
||||
{
|
||||
Argument = new CameraImageUploadInfo
|
||||
{
|
||||
Device = device,
|
||||
FileInfo = file
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||
|
||||
if (WebSocketConnected != null)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(WebSocketConnected, this, new GenericEventArgs<IWebSocketConnection>(connection), _logger);
|
||||
WebSocketConnected?.Invoke(this, new GenericEventArgs<IWebSocketConnection>(connection));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.HttpServer
|
|||
|
||||
void socket_Closed(object sender, EventArgs e)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
|
||||
Closed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.IO
|
|||
Logger.LogDebug("Timer stopped.");
|
||||
|
||||
DisposeTimer();
|
||||
EventHelper.FireEventIfNotNull(Completed, this, EventArgs.Empty, Logger);
|
||||
Completed?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -77,15 +77,14 @@ namespace Emby.Server.Implementations.Library
|
|||
var cacheKey = GetCacheKey(userId, item.Id);
|
||||
_userData.AddOrUpdate(cacheKey, userData, (k, v) => userData);
|
||||
|
||||
EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs
|
||||
UserDataSaved?.Invoke(this, new UserDataSaveEventArgs
|
||||
{
|
||||
Keys = keys,
|
||||
UserData = userData,
|
||||
SaveReason = reason,
|
||||
UserId = user.Id,
|
||||
Item = item
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.Library
|
|||
/// <param name="user">The user.</param>
|
||||
private void OnUserUpdated(User user)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(UserUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
|
||||
UserUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace Emby.Server.Implementations.Library
|
|||
/// <param name="user">The user.</param>
|
||||
private void OnUserDeleted(User user)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(UserDeleted, this, new GenericEventArgs<User> { Argument = user }, _logger);
|
||||
UserDeleted?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -470,10 +470,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
if (fireLockout)
|
||||
{
|
||||
if (UserLockedOut != null)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(UserLockedOut, this, new GenericEventArgs<User>(user), _logger);
|
||||
}
|
||||
UserLockedOut?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -819,7 +816,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
UpdateUser(user);
|
||||
|
||||
EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger);
|
||||
UserPasswordChanged?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
|
||||
public void ChangeEasyPassword(User user, string newPassword, string newPasswordHash)
|
||||
|
@ -843,7 +840,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
UpdateUser(user);
|
||||
|
||||
EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs<User>(user), _logger);
|
||||
UserPasswordChanged?.Invoke(this, new GenericEventArgs<User>(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1087,7 +1084,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
if (fireEvent)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(UserPolicyUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
|
||||
UserPolicyUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1182,7 +1179,7 @@ namespace Emby.Server.Implementations.Library
|
|||
|
||||
if (fireEvent)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(UserConfigurationUpdated, this, new GenericEventArgs<User> { Argument = user }, _logger);
|
||||
UserConfigurationUpdated?.Invoke(this, new GenericEventArgs<User> { Argument = user });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
if (startDate < now)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TimerFired, this, new GenericEventArgs<TimerInfo> { Argument = item }, base.Logger);
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = item });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
|
||||
if (timer != null)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TimerFired, this, new GenericEventArgs<TimerInfo> { Argument = timer }, base.Logger);
|
||||
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo> { Argument = timer });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,13 +144,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
{
|
||||
var timerId = e.Argument;
|
||||
|
||||
EventHelper.FireEventIfNotNull(TimerCancelled, this, new GenericEventArgs<TimerEventInfo>
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = timerId
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
private void EmbyTv_TimerCreated(object sender, GenericEventArgs<TimerInfo> e)
|
||||
|
@ -158,14 +158,14 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
var timer = e.Argument;
|
||||
var service = sender as ILiveTvService;
|
||||
|
||||
EventHelper.FireEventIfNotNull(TimerCreated, this, new GenericEventArgs<TimerEventInfo>
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(timer.ProgramId),
|
||||
Id = timer.Id
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
public ITunerHost[] TunerHosts
|
||||
|
@ -1734,13 +1734,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
|
||||
if (!(service is EmbyTV.EmbyTV))
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TimerCancelled, this, new GenericEventArgs<TimerEventInfo>
|
||||
TimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = id
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1757,13 +1757,13 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
|
||||
await service.CancelSeriesTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
EventHelper.FireEventIfNotNull(SeriesTimerCancelled, this, new GenericEventArgs<TimerEventInfo>
|
||||
SeriesTimerCancelled?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
Id = id
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken)
|
||||
|
@ -2083,14 +2083,14 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
|
||||
if (!(service is EmbyTV.EmbyTV))
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TimerCreated, this, new GenericEventArgs<TimerEventInfo>
|
||||
TimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
|
||||
Id = newTimerId
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2123,14 +2123,14 @@ namespace Emby.Server.Implementations.LiveTv
|
|||
await service.CreateSeriesTimerAsync(info, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
EventHelper.FireEventIfNotNull(SeriesTimerCreated, this, new GenericEventArgs<TimerEventInfo>
|
||||
SeriesTimerCreated?.Invoke(this, new GenericEventArgs<TimerEventInfo>
|
||||
{
|
||||
Argument = new TimerEventInfo
|
||||
{
|
||||
ProgramId = _tvDtoService.GetInternalProgramId(info.ProgramId),
|
||||
Id = newTimerId
|
||||
}
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken)
|
||||
|
|
|
@ -465,11 +465,10 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
|
||||
CurrentProgress = e;
|
||||
|
||||
EventHelper.FireEventIfNotNull(TaskProgress, this, new GenericEventArgs<double>
|
||||
TaskProgress?.Invoke(this, new GenericEventArgs<double>
|
||||
{
|
||||
Argument = e
|
||||
|
||||
}, Logger);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -331,11 +331,10 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
/// <param name="task">The task.</param>
|
||||
internal void OnTaskExecuting(IScheduledTaskWorker task)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TaskExecuting, this, new GenericEventArgs<IScheduledTaskWorker>
|
||||
TaskExecuting?.Invoke(this, new GenericEventArgs<IScheduledTaskWorker>
|
||||
{
|
||||
Argument = task
|
||||
|
||||
}, Logger);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -345,12 +344,11 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
/// <param name="result">The result.</param>
|
||||
internal void OnTaskCompleted(IScheduledTaskWorker task, TaskResult result)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(TaskCompleted, task, new TaskCompletionEventArgs
|
||||
TaskCompleted?.Invoke(task, new TaskCompletionEventArgs
|
||||
{
|
||||
Result = result,
|
||||
Task = task
|
||||
|
||||
}, Logger);
|
||||
});
|
||||
|
||||
ExecuteQueuedTasks();
|
||||
}
|
||||
|
|
|
@ -255,11 +255,10 @@ namespace Emby.Server.Implementations.Session
|
|||
|
||||
if ((activityDate - lastActivityDate).TotalSeconds > 10)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(SessionActivity, this, new SessionEventArgs
|
||||
SessionActivity?.Invoke(this, new SessionEventArgs
|
||||
{
|
||||
SessionInfo = session
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
}
|
||||
|
||||
return session;
|
||||
|
@ -693,7 +692,7 @@ namespace Emby.Server.Implementations.Session
|
|||
}
|
||||
}
|
||||
|
||||
EventHelper.FireEventIfNotNull(PlaybackProgress, this, new PlaybackProgressEventArgs
|
||||
PlaybackProgress?.Invoke(this, new PlaybackProgressEventArgs
|
||||
{
|
||||
Item = libraryItem,
|
||||
Users = users,
|
||||
|
@ -707,8 +706,7 @@ namespace Emby.Server.Implementations.Session
|
|||
PlaySessionId = info.PlaySessionId,
|
||||
IsAutomated = isAutomated,
|
||||
Session = session
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
|
||||
if (!isAutomated)
|
||||
{
|
||||
|
@ -1399,7 +1397,7 @@ namespace Emby.Server.Implementations.Session
|
|||
|
||||
if (result == null)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
||||
AuthenticationFailed?.Invoke(this, new GenericEventArgs<AuthenticationRequest>(request));
|
||||
|
||||
throw new SecurityException("Invalid user or password entered.");
|
||||
}
|
||||
|
@ -1424,7 +1422,7 @@ namespace Emby.Server.Implementations.Session
|
|||
ServerId = _appHost.SystemId
|
||||
};
|
||||
|
||||
EventHelper.FireEventIfNotNull(AuthenticationSucceeded, this, new GenericEventArgs<AuthenticationResult>(returnResult), _logger);
|
||||
AuthenticationSucceeded?.Invoke(this, new GenericEventArgs<AuthenticationResult>(returnResult));
|
||||
|
||||
return returnResult;
|
||||
}
|
||||
|
@ -1587,11 +1585,10 @@ namespace Emby.Server.Implementations.Session
|
|||
|
||||
if (saveCapabilities)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(CapabilitiesChanged, this, new SessionEventArgs
|
||||
CapabilitiesChanged?.Invoke(this, new SessionEventArgs
|
||||
{
|
||||
SessionInfo = session
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
/// <param name="plugin">The plugin.</param>
|
||||
private void OnPluginUninstalled(IPlugin plugin)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(PluginUninstalled, this, new GenericEventArgs<IPlugin> { Argument = plugin }, _logger);
|
||||
PluginUninstalled?.Invoke(this, new GenericEventArgs<IPlugin> { Argument = plugin });
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
{
|
||||
_logger.LogInformation("Plugin updated: {0} {1} {2}", newVersion.name, newVersion.versionStr ?? string.Empty, newVersion.classification);
|
||||
|
||||
EventHelper.FireEventIfNotNull(PluginUpdated, this, new GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> { Argument = new Tuple<IPlugin, PackageVersionInfo>(plugin, newVersion) }, _logger);
|
||||
PluginUpdated?.Invoke(this, new GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> { Argument = new Tuple<IPlugin, PackageVersionInfo>(plugin, newVersion) });
|
||||
|
||||
_applicationHost.NotifyPendingRestart();
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
{
|
||||
_logger.LogInformation("New plugin installed: {0} {1} {2}", package.name, package.versionStr ?? string.Empty, package.classification);
|
||||
|
||||
EventHelper.FireEventIfNotNull(PluginInstalled, this, new GenericEventArgs<PackageVersionInfo> { Argument = package }, _logger);
|
||||
PluginInstalled?.Invoke(this, new GenericEventArgs<PackageVersionInfo> { Argument = package });
|
||||
|
||||
_applicationHost.NotifyPendingRestart();
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
PackageVersionInfo = package
|
||||
};
|
||||
|
||||
EventHelper.FireEventIfNotNull(PackageInstalling, this, installationEventArgs, _logger);
|
||||
PackageInstalling?.Invoke(this, installationEventArgs);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
|
||||
CompletedInstallationsInternal.Add(installationInfo);
|
||||
|
||||
EventHelper.FireEventIfNotNull(PackageInstallationCompleted, this, installationEventArgs, _logger);
|
||||
PackageInstallationCompleted?.Invoke(this, installationEventArgs);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -493,7 +493,7 @@ namespace Emby.Server.Implementations.Updates
|
|||
|
||||
_logger.LogInformation("Package installation cancelled: {0} {1}", package.name, package.versionStr);
|
||||
|
||||
EventHelper.FireEventIfNotNull(PackageInstallationCancelled, this, installationEventArgs, _logger);
|
||||
PackageInstallationCancelled?.Invoke(this, installationEventArgs);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
@ -506,12 +506,11 @@ namespace Emby.Server.Implementations.Updates
|
|||
CurrentInstallations.Remove(tuple);
|
||||
}
|
||||
|
||||
EventHelper.FireEventIfNotNull(PackageInstallationFailed, this, new InstallationFailedEventArgs
|
||||
PackageInstallationFailed?.Invoke(this, new InstallationFailedEventArgs
|
||||
{
|
||||
InstallationInfo = installationInfo,
|
||||
Exception = ex
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -55,15 +55,15 @@ namespace Jellyfin.SocketSharp
|
|||
|
||||
void socket_OnError(object sender, SocketHttpListener.ErrorEventArgs e)
|
||||
{
|
||||
_logger.LogError("Error in SharpWebSocket: {0}", e.Message ?? string.Empty);
|
||||
//EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
|
||||
_logger.LogError("Error in SharpWebSocket: {Message}", e.Message ?? string.Empty);
|
||||
//Closed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
void socket_OnClose(object sender, SocketHttpListener.CloseEventArgs e)
|
||||
{
|
||||
_taskCompletionSource.TrySetResult(true);
|
||||
|
||||
EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
|
||||
Closed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e)
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace MediaBrowser.Common.Events
|
||||
{
|
||||
// TODO: @bond Remove
|
||||
/// <summary>
|
||||
/// Class EventHelper
|
||||
/// </summary>
|
||||
|
@ -59,50 +60,5 @@ namespace MediaBrowser.Common.Events
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the event.
|
||||
/// </summary>
|
||||
/// <param name="handler">The handler.</param>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public static void FireEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger)
|
||||
{
|
||||
if (handler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
handler(sender, args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Error in event handler");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires the event.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="handler">The handler.</param>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="args">The args.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public static void FireEventIfNotNull<T>(EventHandler<T> handler, object sender, T args, ILogger logger)
|
||||
{
|
||||
if (handler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
handler(sender, args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Error in event handler");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,13 +189,12 @@ namespace MediaBrowser.Providers.Subtitles
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(SubtitleDownloadFailure, this, new SubtitleDownloadFailureEventArgs
|
||||
SubtitleDownloadFailure?.Invoke(this, new SubtitleDownloadFailureEventArgs
|
||||
{
|
||||
Item = video,
|
||||
Exception = ex,
|
||||
Provider = provider.Name
|
||||
|
||||
}, _logger);
|
||||
});
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user