Skip to content

Commit 335e975

Browse files
committed
add comments
1 parent f11d053 commit 335e975

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/Moryx.Cli.Templates/Template.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66

77
namespace Moryx.Cli.Templates
88
{
9+
/// <summary>
10+
/// <see cref="Template"/> is used to bring copy files from a template
11+
/// repository to the target solution as defined in a `.moryxtpl`.
12+
///
13+
/// Central functions are
14+
///
15+
/// * `WriteFilesToDisk()`
16+
/// * `ReplacePlaceHoldersInsideFiles()`
17+
/// * Everything that returns a dictionary as for example
18+
/// * `StateBaseFile()`
19+
/// * `Product()`
20+
/// * `Resource()`
21+
///
22+
/// </summary>
23+
/// <example>
24+
/// var dictionary = template.Product(product);
25+
///
26+
/// var files = template.WriteFilesToDisk(dictionary);
27+
/// Template.ReplacePlaceHoldersInsideFiles(
28+
/// files,
29+
/// template.ReplaceVariables(template.Configuration.Add.Product, product)
30+
/// );
31+
/// </example>
932
public class Template
1033
{
1134
private const string IdentifierKey = "{id}";
@@ -177,7 +200,11 @@ public Dictionary<string, string> Module(string name)
177200
public Dictionary<string, string> Resource(string identifier)
178201
=> FilteredFileStructure(_configuration.Add.Resource, identifier);
179202

180-
203+
/// <summary>
204+
/// Replaces placeholders in the files provided to <paramref name="filenames"/>.
205+
/// </summary>
206+
/// <param name="filenames">List of files to be updated</param>
207+
/// <param name="dict">Dictionary of placeholders to be replaced</param>
181208
public static void ReplacePlaceHoldersInsideFiles(IEnumerable<string> filenames, Dictionary<string, string> dict)
182209
{
183210
var tasks = new List<Task>();
@@ -225,6 +252,13 @@ public Dictionary<string, string> PrepareFileStructure(List<string> fileNames, D
225252
f => ReplacePlaceholders(f, patterns)
226253
);
227254

255+
/// <summary>
256+
/// Creates a dictionary of placeholders and their replacements
257+
/// by updating variables (e.g. `{id}`, `{solutionname}`)
258+
/// </summary>
259+
/// <param name="pattern">a <see cref="ConfigurationPattern"/></param>
260+
/// <param name="identifier">Will replace `{id}` in </param>
261+
/// <param name="variables">Custom list of variables to be replaced. E.g. `<"{lang}", "Spanish">`</param>
228262
public Dictionary<string, string> ReplaceVariables(ConfigurationPattern pattern, string identifier = "", Dictionary<string, string>? variables = null)
229263
{
230264
var replacements = pattern.Replacements;
@@ -265,6 +299,12 @@ private static string ReplacePlaceholders(string f, Dictionary<string, string> p
265299
return result;
266300
}
267301

302+
/// <summary>
303+
/// Writes provided files to the file system
304+
/// </summary>
305+
/// <param name="dictionary">A dictionary of files to be copied `from` a source `to` a target</param>
306+
/// <param name="force">Overwrite existing files if true</param>
307+
/// <returns>List of written files</returns>
268308
public IEnumerable<string> WriteFilesToDisk(Dictionary<string, string> dictionary, bool force = false)
269309
{
270310
var result = new List<string>();

0 commit comments

Comments
 (0)