Skip to content
Browse files

Renamed TextThingy to TextResourceFinder and moved Text propertry ass…

…ignment into RazorViewEngine
  • Loading branch information...
1 parent dff2840 commit e76bf556300eaad60b23d2b9230376c0ee3636bf @jchannon jchannon committed
View
2 src/Nancy.Demo.Localisation/Views/razor-layout.cshtml
@@ -11,7 +11,7 @@
<br/>
<a href="/cultureview">Default Culture View Example</a>
<br/>
- <a href="/cultureviewgerman">German Culture ViewExample</a>
+ <a href="/cultureviewgerman">German Culture View Example</a>
</div>
</body>
</html>
View
2 src/Nancy.ViewEngines.Razor/Nancy.ViewEngines.Razor.csproj
@@ -128,7 +128,7 @@
<Compile Include="RazorConfigurationSection.cs" />
<Compile Include="RazorViewEngine.cs" />
<Compile Include="RazorViewEngineApplicationStartupRegistrations.cs" />
- <Compile Include="TextThingy.cs" />
+ <Compile Include="TextResourceFinder.cs" />
<Compile Include="UrlHelpers.cs" />
<Compile Include="VisualBasic\NancyVisualBasicRazorCodeParser.cs" />
<Compile Include="VisualBasic\NancyVisualBasicRazorCodeGenerator.cs" />
View
18 src/Nancy.ViewEngines.Razor/NancyRazorViewBase.cs
@@ -16,7 +16,6 @@ public abstract class NancyRazorViewBase
private readonly StringBuilder contents;
private string childBody;
private IDictionary<string, string> childSections;
- private dynamic text;
/// <summary>
/// Gets the body.
@@ -79,17 +78,10 @@ public bool HasLayout
/// </summary>
public abstract void Execute();
-
- public dynamic Text
- {
- get
- {
- if (text == null)
- text = new TextThingy(this.TextResource);
-
- return text;
- }
- }
+ /// <summary>
+ /// Used to retun text resources
+ /// </summary>
+ public dynamic Text { get; set; }
public ITextResource TextResource { get; set; }
@@ -101,7 +93,6 @@ public dynamic Text
/// <param name="model">The model.</param>
public virtual void Initialize(RazorViewEngine engine, IRenderContext renderContext, object model)
{
- this.TextResource.CurrentCulture = renderContext.Context.Culture;
}
/// <summary>
@@ -331,7 +322,6 @@ public override void Initialize(RazorViewEngine engine, IRenderContext renderCon
this.Model = (TModel)model;
this.Url = new UrlHelpers<TModel>(engine, renderContext);
this.ViewBag = renderContext.Context.ViewBag;
- this.TextResource.CurrentCulture = renderContext.Context.Culture;
}
}
}
View
3 src/Nancy.ViewEngines.Razor/RazorViewEngine.cs
@@ -347,7 +347,8 @@ private NancyRazorViewBase GetOrCompileView(ViewLocationResult viewLocationResul
var view = viewFactory.Invoke();
- view.TextResource = this.textResource;
+ this.textResource.CurrentCulture = renderContext.Context.Culture;
+ view.Text = new TextResourceFinder(this.textResource);
view.Code = string.Empty;
View
26 src/Nancy.ViewEngines.Razor/TextThingy.cs
@@ -1,26 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Dynamic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-
-namespace Nancy.ViewEngines.Razor
-{
- public class TextThingy : DynamicObject
- {
- private readonly ITextResource textResource;
-
- public TextThingy(ITextResource textResource)
- {
- this.textResource = textResource;
- }
-
- public override bool TryGetMember(GetMemberBinder binder, out object result)
- {
- result = this.textResource[binder.Name];
- return true;
- }
- }
-}

0 comments on commit e76bf55

Please sign in to comment.
Something went wrong with that request. Please try again.