using Dinah.Core; using System; using System.Collections.Generic; namespace FileManager { public class NamingTemplate { /// Proposed full name. May contain optional html-styled template tags. Eg: <name> public string Template { get; } /// Proposed file name with optional html-styled template tags. public NamingTemplate(string template) => Template = ArgumentValidator.EnsureNotNullOrWhiteSpace(template, nameof(template)); /// Optional step 1: Replace html-styled template tags with parameters. Eg {"name", "Bill Gates"} => /<name>/ => /Bill Gates/ public Dictionary ParameterReplacements { get; } = new Dictionary(); /// Convenience method public void AddParameterReplacement(string key, object value) // using .Add() instead of "[key] = value" will make unintended overwriting throw exception => ParameterReplacements.Add(key, value); protected static string formatKey(string key) => key .Replace("<", "") .Replace(">", ""); } }