Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #883 from synhershko/master

Minor improvements
  • Loading branch information...
commit 6b2f1b1e388918272ab304836a610e2e9085f89c 2 parents f5c7b0f + 3fb2c9c
@thecodejunkie thecodejunkie authored
Showing with 10 additions and 7 deletions.
  1. +10 −7 src/Nancy/ViewEngines/ResourceViewLocationProvider.cs
View
17 src/Nancy/ViewEngines/ResourceViewLocationProvider.cs
@@ -17,12 +17,12 @@ public class ResourceViewLocationProvider : IViewLocationProvider
/// <summary>
/// User-configured root namespaces for assemblies.
/// </summary>
- public static IDictionary<Assembly, string> RootNamespaces = new Dictionary<Assembly, string>();
+ public readonly static IDictionary<Assembly, string> RootNamespaces = new Dictionary<Assembly, string>();
/// <summary>
/// A list of assemblies to ignore when scanning for embedded views.
/// </summary>
- public static IList<Assembly> Ignore = new List<Assembly>();
+ public readonly static IList<Assembly> Ignore = new List<Assembly>();
/// <summary>
/// Initializes a new instance of the <see cref="ResourceViewLocationProvider"/> class.
@@ -80,11 +80,13 @@ private IEnumerable<ViewLocationResult> GetViewLocations(Assembly assembly, IEnu
throw new InvalidOperationException(errorMessage);
}
- var commonNamespace = RootNamespaces.ContainsKey(assembly) ?
- RootNamespaces[assembly] :
- ExtractAssemblyRootNamespace(assembly);
+ string commonNamespace;
+ if (!RootNamespaces.TryGetValue(assembly, out commonNamespace))
+ {
+ commonNamespace = ExtractAssemblyRootNamespace(assembly);
+ }
- if (string.IsNullOrEmpty(commonNamespace))
+ if (string.IsNullOrWhiteSpace(commonNamespace))
{
return Enumerable.Empty<ViewLocationResult>();
}
@@ -155,7 +157,8 @@ private static string GetResourceFileName(string resourceName)
private static string GetResourceExtension(string resourceName)
{
- return Path.GetExtension(resourceName).Substring(1);
+ var extension = Path.GetExtension(resourceName);
+ return extension != null ? extension.Substring(1) : string.Empty;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.