This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 770
/
TextTemplatingHostContext.cs
57 lines (49 loc) · 1.68 KB
/
TextTemplatingHostContext.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
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.TextTemplating
{
public class TextTemplatingHostContext
{
ITextTemplatingAppDomainFactory appDomainFactory;
ITextTemplatingAssemblyResolver assemblyResolver;
ITextTemplatingVariables templatingVariables;
IServiceProvider serviceProvider;
public TextTemplatingHostContext(IProject project)
: this(
new TextTemplatingAppDomainFactory(),
new TextTemplatingAssemblyResolver(project),
new TextTemplatingVariables(),
new TextTemplatingServiceProvider())
{
}
public TextTemplatingHostContext(
ITextTemplatingAppDomainFactory appDomainFactory,
ITextTemplatingAssemblyResolver assemblyResolver,
ITextTemplatingVariables templatingVariables,
IServiceProvider serviceProvider)
{
this.appDomainFactory = appDomainFactory;
this.assemblyResolver = assemblyResolver;
this.templatingVariables = templatingVariables;
this.serviceProvider = serviceProvider;
}
public object GetService(Type serviceType)
{
return serviceProvider.GetService(serviceType);
}
public string ExpandTemplateVariables(string name)
{
return templatingVariables.ExpandVariables(name);
}
public ITextTemplatingAppDomain CreateTextTemplatingAppDomain(string applicationBase)
{
return appDomainFactory.CreateTextTemplatingAppDomain(applicationBase);
}
public string ResolveAssemblyReference(string assemblyReference)
{
return assemblyResolver.Resolve(assemblyReference);
}
}
}