refactoring, documentation pending

This commit is contained in:
Volodymyr Smirnov
2020-10-26 17:06:29 +02:00
parent 29156b7f10
commit 14c9c26979
39 changed files with 121 additions and 457 deletions

View File

@@ -18,15 +18,12 @@ namespace MalwareMultiScan.Backends.Backends.Abstracts
_logger = logger;
}
protected virtual Regex MatchRegex { get; }
protected virtual string BackendPath { get; }
protected abstract Regex MatchRegex { get; }
protected abstract string BackendPath { get; }
protected virtual bool ParseStdErr { get; }
protected virtual bool ThrowOnNonZeroExitCode { get; } = true;
protected virtual string GetBackendArguments(string path)
{
throw new NotImplementedException();
}
protected abstract string GetBackendArguments(string path);
public override async Task<string[]> ScanAsync(string path, CancellationToken cancellationToken)
{

View File

@@ -3,23 +3,21 @@ using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using MalwareMultiScan.Shared.Interfaces;
using MalwareMultiScan.Backends.Interfaces;
using Microsoft.AspNetCore.Http;
namespace MalwareMultiScan.Backends.Backends.Abstracts
{
public abstract class AbstractScanBackend : IScanBackend
{
public virtual string Id => throw new NotImplementedException();
public abstract string Id { get; }
public virtual Task<string[]> ScanAsync(string path, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public abstract Task<string[]> ScanAsync(string path, CancellationToken cancellationToken);
public async Task<string[]> ScanAsync(Uri uri, CancellationToken cancellationToken)
{
using var httpClient = new HttpClient();
await using var uriStream = await httpClient.GetStreamAsync(uri);
return await ScanAsync(uriStream, cancellationToken);

View File

@@ -1,5 +1,3 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using MalwareMultiScan.Backends.Backends.Abstracts;
using Microsoft.Extensions.Logging;

View File

@@ -2,7 +2,7 @@ using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MalwareMultiScan.Shared.Interfaces;
using MalwareMultiScan.Backends.Interfaces;
using Microsoft.AspNetCore.Http;
namespace MalwareMultiScan.Backends.Backends.Implementations