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