20 changed files with 332 additions and 29 deletions
@ -0,0 +1,19 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
public class CurrentAppDomain : ITextTemplatingAppDomain |
||||||
|
{ |
||||||
|
public AppDomain AppDomain { |
||||||
|
get { return AppDomain.CurrentDomain; } |
||||||
|
} |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
[Serializable] |
||||||
|
public class CurrentAppDomainFactory : ITextTemplatingAppDomainFactory |
||||||
|
{ |
||||||
|
public ITextTemplatingAppDomain CreateTextTemplatingAppDomain(string applicationBase) |
||||||
|
{ |
||||||
|
return new CurrentAppDomain(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
public interface IMvcTextTemplateHostAppDomain : ITextTemplatingAppDomain |
||||||
|
{ |
||||||
|
string ApplicationBase { get; } |
||||||
|
|
||||||
|
IMvcTextTemplateHost CreateMvcTextTemplateHost( |
||||||
|
ITextTemplatingAppDomainFactory appDomainFactory, |
||||||
|
ITextTemplatingAssemblyResolver assemblyResolver, |
||||||
|
string applicationBase); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,13 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
public interface IMvcTextTemplateHostAppDomainFactory |
||||||
|
{ |
||||||
|
IMvcTextTemplateHostAppDomain CreateAppDomain(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
[Serializable] |
||||||
|
public class MvcTextTemplateAssemblyResolver : ITextTemplatingAssemblyResolver |
||||||
|
{ |
||||||
|
public string Resolve(string assemblyReference) |
||||||
|
{ |
||||||
|
return assemblyReference; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
// 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 System.Reflection; |
||||||
|
using ICSharpCode.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
public class MvcTextTemplateHostAppDomain : TextTemplatingAppDomain, IMvcTextTemplateHostAppDomain |
||||||
|
{ |
||||||
|
public MvcTextTemplateHostAppDomain(string applicationBase) |
||||||
|
: base(applicationBase) |
||||||
|
{ |
||||||
|
this.ApplicationBase = applicationBase; |
||||||
|
} |
||||||
|
|
||||||
|
public string ApplicationBase { get; private set; } |
||||||
|
|
||||||
|
public IMvcTextTemplateHost CreateMvcTextTemplateHost( |
||||||
|
ITextTemplatingAppDomainFactory appDomainFactory, |
||||||
|
ITextTemplatingAssemblyResolver assemblyResolver, |
||||||
|
string applicationBase) |
||||||
|
{ |
||||||
|
Type type = typeof(MvcTextTemplateHost); |
||||||
|
var args = new object[] { appDomainFactory, assemblyResolver, applicationBase }; |
||||||
|
|
||||||
|
return (MvcTextTemplateHost)AppDomain.CreateInstanceAndUnwrap( |
||||||
|
type.Assembly.FullName, |
||||||
|
type.FullName, |
||||||
|
false, |
||||||
|
BindingFlags.CreateInstance, |
||||||
|
null, |
||||||
|
args, |
||||||
|
null, |
||||||
|
null); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
// 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 System.IO; |
||||||
|
using ICSharpCode.TextTemplating; |
||||||
|
|
||||||
|
namespace ICSharpCode.AspNet.Mvc |
||||||
|
{ |
||||||
|
public class MvcTextTemplateHostAppDomainFactory : IMvcTextTemplateHostAppDomainFactory |
||||||
|
{ |
||||||
|
public IMvcTextTemplateHostAppDomain CreateAppDomain() |
||||||
|
{ |
||||||
|
string applicationBase = GetAssemblyBaseLocation(); |
||||||
|
return new MvcTextTemplateHostAppDomain(applicationBase); |
||||||
|
} |
||||||
|
|
||||||
|
string GetAssemblyBaseLocation() |
||||||
|
{ |
||||||
|
string location = GetType().Assembly.Location; |
||||||
|
return Path.GetDirectoryName(location); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
// 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.AspNet.Mvc; |
||||||
|
using ICSharpCode.TextTemplating; |
||||||
|
|
||||||
|
namespace AspNet.Mvc.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeMvcTextTemplateAppDomain : IMvcTextTemplateHostAppDomain |
||||||
|
{ |
||||||
|
public string ApplicationBase { get; set; } |
||||||
|
public AppDomain AppDomain { get; set; } |
||||||
|
|
||||||
|
public IMvcTextTemplateHost CreateMvcTextTemplateHost( |
||||||
|
ITextTemplatingAppDomainFactory appDomainFactory, |
||||||
|
ITextTemplatingAssemblyResolver assemblyResolver, |
||||||
|
string applicationBase) |
||||||
|
{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsDisposed; |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
IsDisposed = true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
// 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.AspNet.Mvc; |
||||||
|
|
||||||
|
namespace AspNet.Mvc.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeMvcTextTemplateAppDomainFactory : IMvcTextTemplateHostAppDomainFactory |
||||||
|
{ |
||||||
|
public FakeMvcTextTemplateAppDomain FakeAppDomain = new FakeMvcTextTemplateAppDomain(); |
||||||
|
|
||||||
|
public IMvcTextTemplateHostAppDomain CreateAppDomain() |
||||||
|
{ |
||||||
|
return FakeAppDomain; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
// 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.AspNet.Mvc; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace AspNet.Mvc.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class MvcTextTemplateAssemblyResolverTests |
||||||
|
{ |
||||||
|
MvcTextTemplateAssemblyResolver resolver; |
||||||
|
|
||||||
|
void CreateResolver() |
||||||
|
{ |
||||||
|
resolver = new MvcTextTemplateAssemblyResolver(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Resolve_FullPathToAssemblyPassed_ReturnsFullPathToAssembly() |
||||||
|
{ |
||||||
|
CreateResolver(); |
||||||
|
string expectedAssemblyPath = @"d:\projects\MyProject\bin\debug\MyProject.dll"; |
||||||
|
|
||||||
|
string resolvedAssemblyPath = resolver.Resolve(expectedAssemblyPath); |
||||||
|
|
||||||
|
Assert.AreEqual(expectedAssemblyPath, resolvedAssemblyPath); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue