-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeGeneratorArgs.cs
75 lines (68 loc) · 3.63 KB
/
CodeGeneratorArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/OnRamp
using System;
using System.Collections.Generic;
using System.Reflection;
namespace OnRamp
{
/// <summary>
/// Provides the <see cref="CodeGenerator"/> arguments.
/// </summary>
public class CodeGeneratorArgs : CodeGeneratorArgsBase
{
/// <summary>
/// Creates a new <see cref="CodeGeneratorArgs"/> using the <typeparamref name="T"/> to infer the <see cref="Type.Assembly"/>.
/// </summary>
/// <typeparam name="T">The <see cref="Type"/> to automatically infer the <see cref="Type.Assembly"/> to <see cref="ICodeGeneratorArgs.AddAssembly(Assembly[])">add</see>.</typeparam>
/// <param name="scriptFileName">The script file name.</param>
/// <param name="configFileName">The configuration file name.</param>
/// <returns>A new <see cref="CodeGeneratorArgs"/>.</returns>
public static CodeGeneratorArgs Create<T>(string? scriptFileName = null, string? configFileName = null) => new CodeGeneratorArgs(scriptFileName, configFileName).AddAssembly(typeof(T).Assembly);
/// <summary>
/// Initializes a new instance of the <see cref="CodeGeneratorArgs"/>.
/// </summary>
/// <param name="scriptFileName">The script file name.</param>
/// <param name="configFileName">The configuration file name.</param>
public CodeGeneratorArgs(string? scriptFileName = null, string? configFileName = null)
{
ScriptFileName = scriptFileName;
ConfigFileName = configFileName;
}
/// <summary>
/// Adds (inserts) one or more <paramref name="assemblies"/> to <see cref="ICodeGeneratorArgs.Assemblies"/> (before any existing values).
/// </summary>
/// <param name="assemblies">The assemblies to add.</param>
/// <remarks>The order in which they are specified is the order in which they will be probed for embedded resources.</remarks>
/// <returns>The current <see cref="CodeGeneratorArgs"/> instance to support fluent-style method-chaining.</returns>
public CodeGeneratorArgs AddAssembly(params Assembly[] assemblies)
{
((ICodeGeneratorArgs)this).AddAssembly(assemblies);
return this;
}
/// <summary>
/// Adds (merges) the parameter to the <see cref="ICodeGeneratorArgs.Parameters"/>.
/// </summary>
/// <param name="key">The parameter name.</param>
/// <param name="value">The parameter value.</param>
/// <returns>The current <see cref="CodeGeneratorArgs"/> instance to support fluent-style method-chaining.</returns>
public CodeGeneratorArgs AddParameter<T>(string key, T value)
{
((ICodeGeneratorArgs)this).AddParameter(key, value);
return this;
}
/// <summary>
/// Adds (merges) the <paramref name="parameters"/> to the <see cref="ICodeGeneratorArgs.Parameters"/>.
/// </summary>
/// <param name="parameters">The parameters.</param>
/// <returns>The current <see cref="CodeGeneratorArgs"/> instance to support fluent-style method-chaining.</returns>
public CodeGeneratorArgs AddParameters(IDictionary<string, object?> parameters)
{
((ICodeGeneratorArgs)this).AddParameters(parameters);
return this;
}
/// <summary>
/// Copy and replace from <paramref name="args"/>.
/// </summary>
/// <param name="args">The <see cref="CodeGeneratorArgs"/> to copy from.</param>
public void CopyFrom(CodeGeneratorArgs args) => base.CopyFrom(args);
}
}