diff --git a/Nustache.Core/DefaultContext.cs b/Nustache.Core/DefaultContext.cs
deleted file mode 100644
index 04919de..0000000
--- a/Nustache.Core/DefaultContext.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Reflection;
-
-namespace Nustache.Core
-{
- public class DefaultContext : IContext
- {
- private const BindingFlags DefaultBindingFlags =
- BindingFlags.Instance |
- BindingFlags.Public;
-
- public DefaultContext(object data)
- {
- Current = data;
- }
-
- public object GetValue(string name)
- {
- if (name == ".") return Current;
-
- if (Current == null) return null;
-
- var propertyInfo = Current.GetType().GetProperty(name, DefaultBindingFlags);
-
- if (propertyInfo == null) return "";
-
- var value = propertyInfo.GetValue(Current, null);
-
- return value;
- }
-
- public object Current { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Nustache.Core/EndSection.cs b/Nustache.Core/EndSection.cs
index a87bccf..e228edc 100644
--- a/Nustache.Core/EndSection.cs
+++ b/Nustache.Core/EndSection.cs
@@ -1,5 +1,3 @@
-using System.IO;
-
namespace Nustache.Core
{
public class EndSection : Part
@@ -16,7 +14,7 @@ public string Name
get { return _name; }
}
- public override void Render(TextWriter writer, IContext context)
+ public override void Render(RenderContext context)
{
}
diff --git a/Nustache.Core/IContext.cs b/Nustache.Core/IContext.cs
deleted file mode 100644
index 07a377f..0000000
--- a/Nustache.Core/IContext.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Nustache.Core
-{
- public interface IContext
- {
- object GetValue(string name);
- object Current { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Nustache.Core/LiteralText.cs b/Nustache.Core/LiteralText.cs
index 107dadb..113bcd6 100644
--- a/Nustache.Core/LiteralText.cs
+++ b/Nustache.Core/LiteralText.cs
@@ -1,5 +1,3 @@
-using System.IO;
-
namespace Nustache.Core
{
public class LiteralText : Part
@@ -11,9 +9,9 @@ public LiteralText(string text)
_text = text;
}
- public override void Render(TextWriter writer, IContext context)
+ public override void Render(RenderContext context)
{
- writer.Write(_text);
+ context.Write(_text);
}
#region Boring stuff
diff --git a/Nustache.Core/Nustache.Core.csproj b/Nustache.Core/Nustache.Core.csproj
index d371841..96e65f1 100644
--- a/Nustache.Core/Nustache.Core.csproj
+++ b/Nustache.Core/Nustache.Core.csproj
@@ -45,9 +45,8 @@
-
+
-
diff --git a/Nustache.Core/Part.cs b/Nustache.Core/Part.cs
index 1d214e5..d28d837 100644
--- a/Nustache.Core/Part.cs
+++ b/Nustache.Core/Part.cs
@@ -1,9 +1,7 @@
-using System.IO;
-
namespace Nustache.Core
{
public abstract class Part
{
- public abstract void Render(TextWriter writer, IContext context);
+ public abstract void Render(RenderContext context);
}
}
\ No newline at end of file
diff --git a/Nustache.Core/RenderContext.cs b/Nustache.Core/RenderContext.cs
new file mode 100644
index 0000000..40be207
--- /dev/null
+++ b/Nustache.Core/RenderContext.cs
@@ -0,0 +1,79 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+
+namespace Nustache.Core
+{
+ public class RenderContext
+ {
+ private const BindingFlags DefaultBindingFlags =
+ BindingFlags.Instance |
+ BindingFlags.Public;
+
+ private readonly Stack