diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a0401d0
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,269 @@
+# Supprimer la ligne ci-dessous si vous voulez hériter les paramètres .editorconfig des répertoires supérieurs
+root = true
+
+# Fichiers C#
+[*.cs]
+
+#### Options EditorConfig principales ####
+
+# Indentation et espacement
+indent_size = 4
+indent_style = space
+tab_width = 4
+
+# Préférences de nouvelle ligne
+end_of_line = crlf
+insert_final_newline = false
+
+#### Conventions de codage .NET ####
+
+# Organiser les instructions Using
+dotnet_separate_import_directive_groups = false
+dotnet_sort_system_directives_first = false
+file_header_template = unset
+
+# Préférences de this. et Me.
+dotnet_style_qualification_for_event = false
+dotnet_style_qualification_for_field = false
+dotnet_style_qualification_for_method = false
+dotnet_style_qualification_for_property = false
+
+# Préférences des mots clés de langage par rapport aux types BCL
+dotnet_style_predefined_type_for_locals_parameters_members = true
+dotnet_style_predefined_type_for_member_access = true
+
+# Préférences de parenthèses
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
+
+# Préférences de modificateur
+dotnet_style_require_accessibility_modifiers = for_non_interface_members
+
+# Préférences de niveau expression
+dotnet_style_coalesce_expression = true
+dotnet_style_collection_initializer = true
+dotnet_style_explicit_tuple_names = true
+dotnet_style_namespace_match_folder = true
+dotnet_style_null_propagation = true
+dotnet_style_object_initializer = true
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+dotnet_style_prefer_auto_properties = true
+dotnet_style_prefer_collection_expression = when_types_loosely_match
+dotnet_style_prefer_compound_assignment = true
+dotnet_style_prefer_conditional_expression_over_assignment = true
+dotnet_style_prefer_conditional_expression_over_return = true
+dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
+dotnet_style_prefer_inferred_anonymous_type_member_names = true
+dotnet_style_prefer_inferred_tuple_names = true
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true
+dotnet_style_prefer_simplified_boolean_expressions = true
+dotnet_style_prefer_simplified_interpolation = true
+
+# Préférences de champ
+dotnet_style_readonly_field = true
+
+# Préférences de paramètre
+dotnet_code_quality_unused_parameters = all
+
+# Préférences de suppression
+dotnet_remove_unnecessary_suppression_exclusions = none
+
+# Préférences de nouvelle ligne
+dotnet_style_allow_multiple_blank_lines_experimental = true
+dotnet_style_allow_statement_immediately_after_block_experimental = true
+
+#### Conventions de codage C# ####
+
+# Préférences de var
+csharp_style_var_elsewhere = false:silent
+csharp_style_var_for_built_in_types = false:silent
+csharp_style_var_when_type_is_apparent = false:silent
+
+# Membres expression-bodied
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+
+# Préférences correspondants au modèle
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+csharp_style_prefer_extended_property_pattern = true:suggestion
+csharp_style_prefer_not_pattern = true:suggestion
+csharp_style_prefer_pattern_matching = true:silent
+csharp_style_prefer_switch_expression = true:suggestion
+
+# Préférences de vérification de valeur Null
+csharp_style_conditional_delegate_call = true:suggestion
+
+# Préférences de modificateur
+csharp_prefer_static_local_function = true:suggestion
+csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
+csharp_style_prefer_readonly_struct = true:suggestion
+csharp_style_prefer_readonly_struct_member = true:suggestion
+
+# Préférences de bloc de code
+csharp_prefer_braces = true:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_style_namespace_declarations = block_scoped:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_style_prefer_top_level_statements = true:silent
+
+# Préférences de niveau expression
+csharp_prefer_simple_default_expression = true:suggestion
+csharp_style_deconstructed_variable_declaration = true:suggestion
+csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+csharp_style_prefer_index_operator = true:suggestion
+csharp_style_prefer_local_over_anonymous_function = true:suggestion
+csharp_style_prefer_null_check_over_type_check = true:suggestion
+csharp_style_prefer_range_operator = true:suggestion
+csharp_style_prefer_tuple_swap = true:suggestion
+csharp_style_prefer_utf8_string_literals = true:suggestion
+csharp_style_throw_expression = true:suggestion
+csharp_style_unused_value_assignment_preference = discard_variable:suggestion
+csharp_style_unused_value_expression_statement_preference = discard_variable:silent
+
+# Préférences pour la directive 'using'
+csharp_using_directive_placement = outside_namespace:silent
+
+# Préférences de nouvelle ligne
+csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
+csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
+csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
+csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
+
+#### Règles de formatage C# ####
+
+# Préférences de nouvelle ligne
+csharp_new_line_before_catch = true
+csharp_new_line_before_else = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_anonymous_types = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_open_brace = all
+csharp_new_line_between_query_expression_clauses = true
+
+# Préférences de mise en retrait
+csharp_indent_block_contents = true
+csharp_indent_braces = false
+csharp_indent_case_contents = true
+csharp_indent_case_contents_when_block = true
+csharp_indent_labels = one_less_than_current
+csharp_indent_switch_labels = true
+
+# Préférences d'espace
+csharp_space_after_cast = false
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_after_comma = true
+csharp_space_after_dot = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_after_semicolon_in_for_statement = true
+csharp_space_around_binary_operators = before_and_after
+csharp_space_around_declaration_statements = false
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_before_comma = false
+csharp_space_before_dot = false
+csharp_space_before_open_square_brackets = false
+csharp_space_before_semicolon_in_for_statement = false
+csharp_space_between_empty_square_brackets = false
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_declaration_name_and_open_parenthesis = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_parentheses = false
+csharp_space_between_square_brackets = false
+
+# Préférences d'enveloppement
+csharp_preserve_single_line_blocks = true
+csharp_preserve_single_line_statements = true
+
+#### Styles de nommage ####
+
+# Règles de nommage
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# Spécifications de symboles
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# Styles de nommage
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+[*.{cs,vb}]
+tab_width = 4
+indent_size = 4
+dotnet_style_readonly_field = true:suggestion
+dotnet_style_require_accessibility_modifiers = always:silent
+indent_style = space
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+end_of_line = crlf
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+dotnet_style_explicit_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_compound_assignment = true:suggestion
+dotnet_style_prefer_simplified_interpolation = true:suggestion
+dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
+dotnet_style_namespace_match_folder = true:suggestion
+dotnet_style_allow_multiple_blank_lines_experimental = true:silent
+dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
+dotnet_code_quality_unused_parameters = all:suggestion
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
+dotnet_style_qualification_for_field = false:silent
+dotnet_style_qualification_for_property = false:silent
+dotnet_style_qualification_for_method = false:silent
+dotnet_style_qualification_for_event = false:silent
+dotnet_style_predefined_type_for_locals_parameters_members = true:silent
+dotnet_style_predefined_type_for_member_access = true:silent
\ No newline at end of file
diff --git a/Copy/Config.cs b/Copy/Config.cs
new file mode 100644
index 0000000..42c07de
--- /dev/null
+++ b/Copy/Config.cs
@@ -0,0 +1,134 @@
+using Copy.Types;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Schema.Generation;
+
+namespace Copy
+{
+ ///
+ /// Json serializable configuration class.
+ ///
+ internal class Config
+ {
+ ///
+ /// Path to the configuration file.
+ ///
+ public static string ConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config.json");
+ ///
+ /// Path to the scheme file.
+ ///
+ public static string SchemePath = Path.Combine(Directory.GetCurrentDirectory(), "scheme.json");
+
+ ///
+ /// Indicates if the program is in debug mode.
+ ///
+ [JsonProperty("Debug", Required = Required.DisallowNull)]
+ public bool Debug { get; set; } = false;
+ ///
+ /// List of clients.
+ ///
+ [JsonProperty("Clients", Required = Required.AllowNull)]
+ public List Clients = [];
+
+ ///
+ /// List of tasks.
+ ///
+ [JsonProperty("Tasks", Required = Required.AllowNull)]
+ public List Tasks = [];
+
+ ///
+ /// Load the configuration from the file.
+ ///
+ /// Path to the configuration file.
+ /// Configuration.
+ public static Config Load(string path)
+ {
+ using FileStream stream = new(path, FileMode.Open);
+ using StreamReader reader = new(stream);
+ string json = reader.ReadToEnd();
+ return JsonConvert.DeserializeObject(json) ?? throw new InvalidDataException("Cannot deserialize the configuration.");
+ }
+ ///
+ /// Obtain the JSON scheme of the configuration.
+ ///
+ /// JSON scheme of the configuration.
+ public static string GetScheme()
+ {
+ return new JSchemaGenerator().Generate(typeof(Config)).ToString();
+ }
+ ///
+ /// Obtain the default configuration.
+ ///
+ /// Default configuration.
+ public static string GetDefault()
+ {
+ return JsonConvert.SerializeObject(new Config()
+ {
+
+ Clients = [
+ new Client()
+ {
+ Type = ClientType.FTP,
+ Name = "FTP",
+ Host = "ftp.example.com",
+ Port = 21,
+ Username = "user",
+ Password = "password"
+ },
+ new Client()
+ {
+ Type = ClientType.SFTP,
+ Name = "SFTP",
+ Host = "sftp.example.com",
+ Port = 22,
+ Username = "user",
+ Password = "password"
+ },
+ new Client()
+ {
+ Type = ClientType.Local,
+ Name = "Local",
+ Host = "localhost",
+ },
+ new Client()
+ {
+ Type = ClientType.Exchange,
+ Name = "Exchange",
+ Host = "exchange.example.com",
+ Username = "user@example.com",
+ Password = "password"
+ }
+ ],
+ Tasks = [
+ new CopyTask()
+ {
+ Client = "FTP",
+ Source = "source",
+ Destination = "destination",
+ Delete = true
+ },
+ new CopyTask()
+ {
+ Source = "source",
+ Destination = "destination",
+ Client = "SFTP",
+ Filter = "*.txt"
+ },
+ new CopyTask()
+ {
+ Source = "source",
+ Destination = "destination",
+ Client = "Local",
+ Delete = true,
+ Filter = "*.txt"
+ },
+ new CopyTask()
+ {
+ Source = "source",
+ Destination = "destination",
+ Client = "Exchange"
+ }
+ ]
+ }, Formatting.Indented);
+ }
+ }
+}
diff --git a/Copy/Copy.csproj b/Copy/Copy.csproj
index 2150e37..4c3a9dd 100644
--- a/Copy/Copy.csproj
+++ b/Copy/Copy.csproj
@@ -1,10 +1,21 @@
-
- Exe
- net8.0
- enable
- enable
-
+
+ Exe
+ net8.0
+ latest
+ enable
+ enable
+ true
+ true
+ FRFlo.Copy
+ FRFlo
+ Copy software scoped for professional use
+
+
+
+
+
+
diff --git a/Copy/Helpers/EnumExtensions.cs b/Copy/Helpers/EnumExtensions.cs
new file mode 100644
index 0000000..5333b14
--- /dev/null
+++ b/Copy/Helpers/EnumExtensions.cs
@@ -0,0 +1,44 @@
+using System.ComponentModel;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace Copy.Helpers
+{
+ ///
+ /// Extension methods for class.
+ ///
+ public static class EnumExtensions
+ {
+
+ ///
+ /// Retrieves the value of an attribute of an enum value.
+ ///
+ /// Attribute type
+ /// Enum value
+ /// Attribute value
+ public static T? GetAttribute(this Enum value) where T : Attribute
+ {
+ return value.GetType()
+ .GetMember(value.ToString())
+ .FirstOrDefault()?
+ .GetCustomAttribute();
+ }
+ ///
+ /// Retrieves the description of an enum value.
+ ///
+ /// Enum value
+ /// Description
+ public static string GetDescription(this Enum value)
+ {
+ return value.GetAttribute()?.Description ?? value.ToString();
+ }
+ ///
+ /// Retrieves the value of an of an enum value.
+ ///
+ /// Enum value
+ public static string GetEnumMember(this Enum value)
+ {
+ return value.GetAttribute()?.Value ?? value.ToString();
+ }
+ }
+}
diff --git a/Copy/Logger.cs b/Copy/Logger.cs
new file mode 100644
index 0000000..8196b1f
--- /dev/null
+++ b/Copy/Logger.cs
@@ -0,0 +1,137 @@
+using System.Text;
+
+namespace CSBase
+{
+ ///
+ /// Logger class.
+ ///
+ public static class Logger
+ {
+ ///
+ /// Indicates if the program is in debug mode.
+ ///
+ public static bool IsDebug { get; set; } = false;
+ ///
+ /// Path to the log file.
+ ///
+ /// - In debug mode, it is located in the program folder with the name "debug.log".
+ /// - In production mode, it is located in the program folder with the name "production.log".
+ ///
+ ///
+ public static string LogFilePath { get; set; } = Path.Combine(Directory.GetCurrentDirectory(),
+#if DEBUG
+ "debug.log");
+#else
+ "production.log");
+#endif
+ ///
+ /// Indicates if the logger should write logs to the file.
+ ///
+ public static bool LogToFile { get; set; } = true;
+ ///
+ /// Shows a message in the console and writes it to the log file.
+ ///
+ /// Prefix of the message
+ /// Color of the prefix
+ /// Message to show
+ /// Color of the message
+ /// Icon to show before the message
+ private static void Print(string prefix, ConsoleColor prefixColor, string message, ConsoleColor color = ConsoleColor.White, LoggerIcon? icon = null)
+ {
+ StringBuilder sb = new();
+ if (message.EndsWith('\n'))
+ {
+ message = message[..^1];
+ }
+
+ if (prefix != "DEBUG" || IsDebug)
+ {
+ foreach (string line in message.Split('\n'))
+ {
+ Console.ForegroundColor = ConsoleColor.Gray;
+ Console.Write($"{DateTime.Now:dd/MM/yyyy, HH:mm:fff} ");
+ Console.BackgroundColor = prefixColor;
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.Write(prefix);
+ if (icon != null)
+ {
+ Console.BackgroundColor = icon.BackgroundColor;
+ Console.ForegroundColor = icon.ForegroundColor;
+ Console.Write($" {icon.Icon} ");
+ }
+ Console.BackgroundColor = ConsoleColor.Black;
+ Console.ForegroundColor = color;
+ Console.WriteLine($" {line}");
+ Console.ResetColor();
+
+ sb.Append($"{DateTime.Now:dd/MM/yyyy, HH:mm:fff} {prefix} {line}\n");
+ }
+ }
+ string final = sb.ToString();
+
+ if (LogToFile) File.AppendAllText(LogFilePath, final, Encoding.UTF8);
+ }
+
+ ///
+ /// Shows a debug message in the console and writes it to the log file.
+ ///
+ /// Message to show
+ /// Icon to show before the message
+ public static void Debug(string message, LoggerIcon? icon = null)
+ {
+ Print("DEBUG", ConsoleColor.DarkGreen, message, ConsoleColor.Green, icon);
+ }
+
+ ///
+ /// Shows a info message in the console and writes it to the log file.
+ ///
+ /// Message to show
+ /// Icon to show before the message
+ public static void Info(string message, LoggerIcon? icon = null)
+ {
+ Print("INFO", ConsoleColor.DarkBlue, message, ConsoleColor.Blue, icon);
+ }
+
+ ///
+ /// Shows a warn message in the console and writes it to the log file.
+ ///
+ /// Message to show
+ /// Icon to show before the message
+ public static void Warn(string message, LoggerIcon? icon = null)
+ {
+ Print("WARN", ConsoleColor.DarkYellow, message, ConsoleColor.Yellow, icon);
+ }
+
+ ///
+ /// Shows a error message in the console and writes it to the log file.
+ ///
+ /// Message to show
+ /// Icon to show before the message
+ public static void Error(string message, LoggerIcon? icon = null)
+ {
+ Print("ERREUR", ConsoleColor.DarkRed, message, ConsoleColor.Red, icon);
+ }
+ }
+
+ ///
+ /// Class to define an icon for the logger.
+ ///
+ /// Unicode text defining the icon
+ /// Foreground color of the icon
+ /// Background color of the icon
+ public class LoggerIcon(string icon, ConsoleColor iconColor, ConsoleColor iconBackground)
+ {
+ ///
+ /// Unicode text defining the icon
+ ///
+ public string Icon { get; set; } = icon;
+ ///
+ /// Foreground color of the icon
+ ///
+ public ConsoleColor ForegroundColor { get; set; } = iconColor;
+ ///
+ /// Background color of the icon
+ ///
+ public ConsoleColor BackgroundColor { get; set; } = iconBackground;
+ }
+}
diff --git a/Copy/Program.cs b/Copy/Program.cs
index 3751555..ed3dcc5 100644
--- a/Copy/Program.cs
+++ b/Copy/Program.cs
@@ -1,2 +1,23 @@
-// See https://aka.ms/new-console-template for more information
-Console.WriteLine("Hello, World!");
+namespace Copy
+{
+ internal class Program
+ {
+ internal static Config Config = Config.Load(Config.ConfigPath);
+ public static void Main(string[] args)
+ {
+ if (args.Length > 0)
+ {
+ switch (args[0])
+ {
+ case "config":
+ File.WriteAllText(Config.SchemePath, Config.GetScheme());
+ File.WriteAllText(Config.ConfigPath, Config.GetDefault());
+ break;
+ default:
+ Config.ConfigPath = args[0];
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/Copy/Types/Client.cs b/Copy/Types/Client.cs
new file mode 100644
index 0000000..dd29383
--- /dev/null
+++ b/Copy/Types/Client.cs
@@ -0,0 +1,67 @@
+using Newtonsoft.Json;
+using System.Runtime.Serialization;
+
+namespace Copy.Types
+{
+ ///
+ /// Type of client used to copy files.
+ ///
+ internal enum ClientType
+ {
+ [EnumMember(Value = "FTP")]
+ FTP,
+ [EnumMember(Value = "SFTP")]
+ SFTP,
+ [EnumMember(Value = "Local")]
+ Local,
+ [EnumMember(Value = "Exchange")]
+ Exchange
+ }
+ ///
+ /// Client used to copy files.
+ ///
+ internal class Client
+ {
+ private int? _port = null;
+ ///
+ /// Type of client.
+ ///
+ [JsonProperty(PropertyName = "Type", Required = Required.Always)]
+ public required ClientType Type { get; set; }
+ ///
+ /// Name of the client.
+ ///
+ [JsonProperty(PropertyName = "Name", Required = Required.Always)]
+ public required string Name { get; set; }
+ ///
+ /// Host of the client.
+ ///
+ [JsonProperty(PropertyName = "Host", Required = Required.Always)]
+ public required string Host { get; set; }
+ ///
+ /// Port of the client.
+ ///
+ [JsonProperty(PropertyName = "Port", Required = Required.DisallowNull)]
+ public int Port
+ {
+ get => _port ?? (Type switch
+ {
+ ClientType.FTP => 21,
+ ClientType.SFTP => 22,
+ ClientType.Exchange => 443,
+ _ => 0
+ });
+ set => _port = value;
+ }
+ ///
+ /// Username of the client.
+ ///
+ [JsonProperty(PropertyName = "Username", Required = Required.Default)]
+ public string? Username { get; set; }
+ ///
+ /// Password of the client.
+ ///
+ [JsonProperty(PropertyName = "Password", Required = Required.Default)]
+ public string? Password { get; set; }
+ }
+}
diff --git a/Copy/Types/CopyTask.cs b/Copy/Types/CopyTask.cs
new file mode 100644
index 0000000..2dff5be
--- /dev/null
+++ b/Copy/Types/CopyTask.cs
@@ -0,0 +1,36 @@
+using Newtonsoft.Json;
+
+namespace Copy.Types
+{
+ ///
+ /// Task to copy files.
+ ///
+ public class CopyTask
+ {
+ ///
+ /// Client to use for the task.
+ ///
+ [JsonProperty(PropertyName = "Client", Required = Required.Always)]
+ public required string Client { get; set; }
+ ///
+ /// Source of files to copy.
+ ///
+ [JsonProperty(PropertyName = "Source", Required = Required.Always)]
+ public required string Source { get; set; }
+ ///
+ /// Destination of files to copy.
+ ///
+ [JsonProperty(PropertyName = "Destination", Required = Required.Always)]
+ public required string Destination { get; set; }
+ ///
+ /// Whether to delete files after copying.
+ ///
+ [JsonProperty(PropertyName = "Delete", Required = Required.DisallowNull)]
+ public bool Delete { get; set; } = false;
+ ///
+ /// Filter for files to copy.
+ ///
+ [JsonProperty(PropertyName = "Filter", Required = Required.DisallowNull)]
+ public string Filter { get; set; } = "*.*";
+ }
+}
\ No newline at end of file
diff --git a/Copy/Types/Singleton.cs b/Copy/Types/Singleton.cs
new file mode 100644
index 0000000..567c9b5
--- /dev/null
+++ b/Copy/Types/Singleton.cs
@@ -0,0 +1,33 @@
+namespace Copy.Types
+{
+ ///
+ /// Base class for a thread safe singleton.
+ ///
+ /// Singleton type
+ public abstract class Singleton where T : new()
+ {
+ ///
+ /// Padlock object for thread safety.
+ ///
+ private static readonly object _padlock = new();
+ ///
+ /// Nullable instance of the class.
+ ///
+ private static T? _instance;
+
+ ///
+ /// Instance of class.
+ ///
+ public static T Instance
+ {
+ get
+ {
+ lock (_padlock)
+ {
+ return _instance ??= new T();
+ }
+ }
+ set => _instance = value;
+ }
+ }
+}