using Mlaumcherb.Client.Avalonia.классы;

namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;

public class ModpackDownloadTaskFactory : INetworkTaskFactory
{
    INetworkTaskFactory _implementationVersion;

    public ModpackDownloadTaskFactory(GameVersionDescriptor descriptor)
    {
        if(descriptor.modpack is null)
            throw new ArgumentNullException(nameof(descriptor.modpack));
        
        _implementationVersion = descriptor.modpack.format_version switch
        {
            2 => new MyModpackV2DownloadTaskFactory(descriptor),
            _ => throw new Exception($"Unknown Modpack format_version: {descriptor.modpack.format_version}")
        };
    }

    public Task<NetworkTask?> CreateAsync(bool checkHashes)
    {
        return _implementationVersion.CreateAsync(checkHashes);
    }
}