af1152b001
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
// <copyright file="EventHelper.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace MediaBrowser.Common.Events
|
|
{
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
/// <summary>
|
|
/// Class EventHelper.
|
|
/// </summary>
|
|
// TODO: @bond Remove
|
|
public static class EventHelper
|
|
{
|
|
/// <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 QueueEventIfNotNull(EventHandler? handler, object sender, EventArgs args, ILogger logger)
|
|
{
|
|
if (handler is not null)
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
handler(sender, args);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "Error in event handler");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Queues the event.
|
|
/// </summary>
|
|
/// <typeparam name="T">Argument type for the <c>handler</c>.</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 QueueEventIfNotNull<T>(EventHandler<T>? handler, object sender, T args, ILogger logger)
|
|
{
|
|
if (handler is not null)
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
handler(sender, args);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "Error in event handler");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|