-
Notifications
You must be signed in to change notification settings - Fork 378
/
Copy pathITemplateEngineHost.cs
85 lines (72 loc) · 3.92 KB
/
ITemplateEngineHost.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
76
77
78
79
80
81
82
83
84
85
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Logging;
using Microsoft.TemplateEngine.Abstractions.PhysicalFileSystem;
namespace Microsoft.TemplateEngine.Abstractions
{
/// <summary>
/// Gets host-specific properties, loggers and provides access to file system.
/// </summary>
public interface ITemplateEngineHost : IDisposable
{
/// <summary>
/// Gets the list of built-in components provided by the host.
/// </summary>
IReadOnlyList<(Type InterfaceType, IIdentifiedComponent Instance)> BuiltInComponents { get; }
/// <summary>
/// Provides access to file system.
/// Depending on the settings, the file system can be physical or in-memory or both depending on the file path.
/// To virtualize certain file path, use <see cref="VirtualizeDirectory(string)"/>.
/// </summary>
IPhysicalFileSystem FileSystem { get; }
/// <summary>
/// Gets the identifier of the host.
/// </summary>
string HostIdentifier { get; }
/// <summary>
/// Gets the fallback names that will be probed to locate the host specific template settings file.
/// The primary host template config name is <see cref="HostIdentifier"/>.
/// </summary>
IReadOnlyList<string> FallbackHostTemplateConfigNames { get; }
/// <summary>
/// Gets default logger for given template engine host.
/// </summary>
ILogger Logger { get; }
/// <summary>
/// Gets logger factory for given template engine host.
/// </summary>
ILoggerFactory LoggerFactory { get; }
/// <summary>
/// Gets the version of the host.
/// </summary>
string Version { get; }
/// <summary>
/// Tries to get default host parameter by its name.
/// </summary>
/// <param name="paramName">Name of the parameter.</param>
/// <param name="value">Default value of the parameter provided by the host.</param>
/// <returns>true - if default value was provided; false otherwise.</returns>
bool TryGetHostParamDefault(string paramName, out string? value);
/// <summary>
/// Virtualizes access to the <paramref name="path"/>. After the location is virtualized, the file read/writes will be done from/to memory instead of physical file system. All subfolders in the location will be also virtualized.
/// </summary>
/// <param name="path"></param>
void VirtualizeDirectory(string path);
#region Obsolete
/// <summary>
/// Action to be done when potentially destructive changes on template instantiation are detected.
/// The host can implement it as needed: prompt user, show error, etc.
/// In case template instantiation should proceed, the method should return true.
/// In case template instantiation should be aborted, the method should return false.
/// </summary>
/// <param name="changes">the list of file changes to be done on template instantiation.</param>
/// <param name="destructiveChanges">the list of destructive file changes (modify/remove) to be performed on template instantiation.</param>
/// <returns>
/// true - in case template engine should proceed with template instantiation and perform destructive changes;
/// false - if the template instantiation should be aborted.
/// </returns>
[Obsolete("The method is deprecated. If potentially destructive changes are detected without passing force, TemplateCreator will return DestructiveChangesDetected CreationResultStatus that can be processed by host.")]
bool OnPotentiallyDestructiveChangesDetected(IReadOnlyList<IFileChange> changes, IReadOnlyList<IFileChange> destructiveChanges);
#endregion
}
}