-
Notifications
You must be signed in to change notification settings - Fork 5
/
CodeGenerationContext.cs
56 lines (50 loc) · 2 KB
/
CodeGenerationContext.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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CodeGenerationContext.cs" company="Kephas Software SRL">
// Copyright (c) Kephas Software SRL. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// <summary>
// Implements the code generation context class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Kephas.CodeAnalysis.Generation
{
using System;
using Kephas.Services;
/// <summary>
/// A code generation context.
/// </summary>
public class CodeGenerationContext : Context, ICodeGenerationContext
{
/// <summary>
/// Initializes a new instance of the <see cref="CodeGenerationContext"/> class.
/// </summary>
/// <param name="serviceProvider">The injector.</param>
/// <param name="codeGenerator">The code generator.</param>
/// <param name="codeFormatter">Optional. The code formatter.</param>
public CodeGenerationContext(
IServiceProvider serviceProvider,
ICodeGenerator codeGenerator,
ICodeFormatter? codeFormatter = null)
: base(serviceProvider)
{
codeGenerator = codeGenerator ?? throw new ArgumentNullException(nameof(codeGenerator));
this.CodeGenerator = codeGenerator;
this.CodeFormatter = codeFormatter ?? new CodeFormatter();
}
/// <summary>
/// Gets the code generator.
/// </summary>
/// <value>
/// The code generator.
/// </value>
public ICodeGenerator CodeGenerator { get; }
/// <summary>
/// Gets the code formatter.
/// </summary>
/// <value>
/// The code formatter.
/// </value>
public ICodeFormatter CodeFormatter { get; }
}
}