using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace Hast.Layer;
public static class HastlayerExtensions
{
///
/// Generates a proxy for the given object that will transfer suitable calls to the hardware implementation using
/// the default proxy generation configuration.
///
/// Type of the object to generate a proxy for.
/// The representation of the assemblies implemented as hardware.
/// The object to generate the proxy for.
/// The generated proxy object.
///
/// Thrown if any lower-level exception or other error happens during proxy generation.
///
public static Task GenerateProxyAsync(
this IHastlayer hastlayer,
IHardwareRepresentation hardwareRepresentation,
T hardwareObject)
where T : class =>
hastlayer.GenerateProxyAsync(hardwareRepresentation, hardwareObject, ProxyGenerationConfiguration.Default);
///
/// Generates and implements a hardware representation of the given assemblies. Be sure to use assemblies built with
/// the Debug configuration.
///
/// The assemblies that should be implemented as hardware.
/// Configuration for how the hardware generation should happen.
/// The representation of the assemblies implemented as hardware.
///
/// Thrown if any lower-level exception or other error happens during hardware generation.
///
public static Task GenerateHardwareAsync(
this IHastlayer hastlayer,
IEnumerable assemblies,
IHardwareGenerationConfiguration configuration) =>
hastlayer.GenerateHardwareAsync(assemblies.Select(assembly => assembly.Location), configuration);
}