Skip to content
Browse files

Passed in NancyContext rather than just culture name string

  • Loading branch information...
1 parent b3333f3 commit 64b95281efeadc6d9d8e3d2a6e29b056225fd118 @jchannon jchannon committed Dec 20, 2012
View
6 src/Nancy.ViewEngines.Razor/DefaultTextResource.cs
@@ -25,7 +25,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}
- public string this[string key, string culture]
+ public string this[string key, NancyContext context]
{
get
{
@@ -35,10 +35,10 @@ IEnumerator IEnumerable.GetEnumerator()
}
- return dictionary[key].ContainsKey(culture) ? dictionary[key][culture] : null;
+ return dictionary[key].ContainsKey(context.Culture.Name) ? dictionary[key][context.Culture.Name] : null;
}
- set { dictionary[key][culture] = value; }
+ set { dictionary[key][context.Culture.Name] = value; }
}
}
View
2 src/Nancy.ViewEngines.Razor/ITextResource.cs
@@ -6,6 +6,6 @@ namespace Nancy.ViewEngines.Razor
public interface ITextResource : IEnumerable<KeyValuePair<string, IDictionary<string, string>>>
{
- string this[string key, string culture] { get; set; }
+ string this[string key, NancyContext context] { get; set; }
}
}
View
1 src/Nancy.ViewEngines.Razor/Nancy.ViewEngines.Razor.csproj
@@ -117,7 +117,6 @@
<Compile Include="ITextResource.cs" />
<Compile Include="IRazorConfiguration.cs" />
<Compile Include="IRazorViewRenderer.cs" />
- <Compile Include="ITextResourceFinder.cs" />
<Compile Include="ModelFinder.cs" />
<Compile Include="ModelSpan.cs" />
<Compile Include="CSharp\NancyCSharpRazorCodeGenerator.cs" />
View
2 src/Nancy.ViewEngines.Razor/RazorViewEngine.cs
@@ -347,7 +347,7 @@ private NancyRazorViewBase GetOrCompileView(ViewLocationResult viewLocationResul
var view = viewFactory.Invoke();
- view.Text = new TextResourceFinder(this.textResource, renderContext.Context.Culture.Name);
+ view.Text = new TextResourceFinder(this.textResource, renderContext.Context);
view.Code = string.Empty;
View
10 src/Nancy.ViewEngines.Razor/TextResourceFinder.cs
@@ -8,20 +8,20 @@
namespace Nancy.ViewEngines.Razor
{
- public class TextResourceFinder : DynamicObject, ITextResourceFinder
+ public class TextResourceFinder : DynamicObject
{
private readonly ITextResource textResource;
- private readonly string culture;
+ private readonly NancyContext context;
- public TextResourceFinder(ITextResource textResource, string culture)
+ public TextResourceFinder(ITextResource textResource, NancyContext context)
{
this.textResource = textResource;
- this.culture = culture;
+ this.context = context;
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
- result = this.textResource[binder.Name, this.culture];
+ result = this.textResource[binder.Name, this.context];
return true;
}
}

0 comments on commit 64b9528

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