using System;
using System.Collections.Generic;
namespace AggregateConfigBuildTask.FileHandlers
{
///
/// Factory class for creating appropriate file handlers and retrieving expected file extensions based on file type.
///
public static class FileHandlerFactory
{
///
/// Returns the appropriate implementation based on the specified file format.
///
/// The file system interface to be used by the handler.
/// The file type for which a handler is needed.
/// An instance of suitable for handling the specified format.
/// Thrown when an unsupported file format is provided.
internal static IFileHandler GetFileHandlerForType(IFileSystem fileSystem, FileType format)
{
switch (format)
{
case FileType.Json:
return new JsonFileHandler(fileSystem);
case FileType.Yaml:
return new YamlFileHandler(fileSystem);
case FileType.Arm:
return new ArmParametersFileHandler(fileSystem);
default:
throw new ArgumentException("Unsupported format", nameof(format));
}
}
///
/// Retrieves a list of file extensions that are expected for the specified file type.
///
/// The file type for which expected file extensions are requested.
/// A list of strings representing valid file extensions for the input type.
/// Thrown when an unsupported file type is provided.
internal static List GetExpectedFileExtensions(FileType inputType)
{
switch (inputType)
{
case FileType.Json:
return new List { ".json" };
case FileType.Yaml:
return new List { ".yml", ".yaml" };
case FileType.Arm:
return new List { ".json" };
default:
throw new ArgumentException("Unsupported input type", nameof(inputType));
}
}
}
}