Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Added null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jchannon committed Dec 21, 2012
1 parent dfb4b84 commit e0c9edd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Nancy/ViewEngines/DefaultTextResource.cs
Expand Up @@ -15,14 +15,19 @@ public DefaultTextResource()
var assemblies = AppDomain.CurrentDomain.GetAssemblies();

culturedAssembly = assemblies.FirstOrDefault(x => x.GetManifestResourceNames().Any(y => y.Contains("Text.")));

resourceManager = new ResourceManager(culturedAssembly.GetName().Name + ".Resources.Text", culturedAssembly);
if (culturedAssembly != null)
{
resourceManager = new ResourceManager(culturedAssembly.GetName().Name + ".Resources.Text",
culturedAssembly);
}
}

public string this[string key, NancyContext context]
{
get
{
if (resourceManager == null)
return null;

return resourceManager.GetString(key, context.Culture);
}
Expand Down

0 comments on commit e0c9edd

Please sign in to comment.