Files
annotations/Azaion.CommonSecurity/Services/ResourceLoader.cs
T
Alex Bezdieniezhnykh 0c66607ed7 failsafe load dlls
add user config queue offsets
throttle improvements
2025-04-17 01:19:48 +03:00

23 lines
766 B
C#

using Azaion.CommonSecurity.DTO.Commands;
using Microsoft.Extensions.DependencyInjection;
namespace Azaion.CommonSecurity.Services;
public interface IResourceLoader
{
MemoryStream LoadFile(string fileName, string? folder = null);
}
public class ResourceLoader([FromKeyedServices(SecurityConstants.EXTERNAL_INFERENCE_PATH)] IInferenceClient inferenceClient) : IResourceLoader
{
public MemoryStream LoadFile(string fileName, string? folder = null)
{
inferenceClient.Send(RemoteCommand.Create(CommandType.Load, new LoadFileData(fileName, folder)));
var bytes = inferenceClient.GetBytes(2, 3);
if (bytes == null)
throw new Exception($"Unable to receive {fileName}");
return new MemoryStream(bytes);
}
}