#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

63 lines
1.5 KiB

// 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 Mono.TextTemplating;
namespace ICSharpCode.TextTemplating
{
public class TextTemplatingHost : TemplateGenerator, ITextTemplatingHost, IServiceProvider
{
ITextTemplatingAppDomain templatingAppDomain;
TextTemplatingHostContext context;
string applicationBase;
public TextTemplatingHost(TextTemplatingHostContext context, string applicationBase)
{
this.context = context;
this.applicationBase = applicationBase;
}
public void Dispose()
{
if (templatingAppDomain != null) {
templatingAppDomain.Dispose();
templatingAppDomain = null;
}
}
public override AppDomain ProvideTemplatingAppDomain(string content)
{
if (templatingAppDomain == null) {
CreateAppDomain();
}
return templatingAppDomain.AppDomain;
}
void CreateAppDomain()
{
templatingAppDomain = context.CreateTextTemplatingAppDomain(applicationBase);
}
protected override string ResolveAssemblyReference(string assemblyReference)
{
return context.ResolveAssemblyReference(assemblyReference);
}
protected override string ResolvePath(string path)
{
path = ExpandPath(path);
return base.ResolvePath(path);
}
string ExpandPath(string path)
{
return context.ExpandTemplateVariables(path);
}
object IServiceProvider.GetService(Type serviceType)
{
return context.GetService(serviceType);
}
}
}