using System.Reflection;
namespace RemoteExec.Server;
///
/// Event arguments for assembly request events.
///
public class RequestAssemblyEventArgs(AssemblyName assemblyName) : EventArgs
{
private readonly TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
private Assembly? assembly = null;
///
/// Gets the assembly name being requested.
///
public AssemblyName Assembly { get; } = assemblyName;
///
/// Asynchronously waits for the assembly to be provided.
///
/// The assembly, or null if not provided.
public async Task GetAssemblyAsync()
{
await taskCompletionSource.Task;
return assembly;
}
///
/// Sets the assembly to fulfill the request.
///
/// The assembly to provide.
public void SetAssembly(Assembly assembly)
{
this.assembly = assembly;
taskCompletionSource.SetResult();
}
}