diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderBase.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderBase.cs
index 922d08dd..f3991973 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderBase.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderBase.cs
@@ -22,13 +22,16 @@ public abstract class DynamicNodeProviderBase
///
/// Determines whether the provider instance matches the name
///
- /// The name of the dynamic node provider. This can be any string, but for backward compatibility the type name can be used.
+ /// The name of the dynamic node provider. This can be any string, but for backward compatibility the type name is used.
///
/// True if the provider name matches.
///
public virtual bool AppliesTo(string providerName)
{
- return this.GetType().ShortAssemblyQualifiedName().Equals(providerName, StringComparison.InvariantCulture);
+ if (string.IsNullOrEmpty(providerName))
+ return false;
+
+ return this.GetType().Equals(Type.GetType(providerName, false));
}
#endregion
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderStrategy.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderStrategy.cs
index b248b08f..ccb659d5 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderStrategy.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/DynamicNodeProviderStrategy.cs
@@ -6,7 +6,7 @@ namespace MvcSiteMapProvider
{
///
/// Tracks all of the registered instances of and
- /// allows the caller to get a specific named instance of this interface at runtime.
+ /// allows the caller to get a specific named instance of at runtime.
///
public class DynamicNodeProviderStrategy
: IDynamicNodeProviderStrategy
@@ -25,13 +25,19 @@ public DynamicNodeProviderStrategy(IDynamicNodeProvider[] dynamicNodeProviders)
public IDynamicNodeProvider GetProvider(string providerName)
{
- return dynamicNodeProviders.FirstOrDefault(x => x.AppliesTo(providerName));
+ var provider = this.dynamicNodeProviders.FirstOrDefault(x => x.AppliesTo(providerName));
+ if (provider == null && !string.IsNullOrEmpty(providerName))
+ {
+ throw new MvcSiteMapException(string.Format(Resources.Messages.NamedDynamicNodeProviderNotFound, providerName));
+ }
+
+ return provider;
}
public IEnumerable GetDynamicNodeCollection(string providerName, ISiteMapNode node)
{
- var provider = GetProvider(providerName);
- if (provider == null) return new List();
+ var provider = this.GetProvider(providerName);
+ if (provider == null) return new List(); // No provider, return empty collection
return provider.GetDynamicNodeCollection(node);
}
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.Designer.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.Designer.cs
index bb0e2703..f2bb2e1c 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.Designer.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18408
+// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -217,6 +217,15 @@ internal static string NamedBuilderSetNotFound {
}
}
+ ///
+ /// Looks up a localized string similar to The dynamic node provider instance named '{0}' was not found. Check your DI configuration to ensure a dynamic node provider instance with this name exists and is configured correctly..
+ ///
+ internal static string NamedDynamicNodeProviderNotFound {
+ get {
+ return ResourceManager.GetString("NamedDynamicNodeProviderNotFound", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to The visibility provider instance named '{0}' was not found. Check your DI configuration to ensure a visibility provider instance with this name exists and is configured correctly..
///
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.resx b/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.resx
index b8eb6fa0..c7ac2df5 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.resx
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/Resources/Messages.resx
@@ -374,4 +374,7 @@ Valid keys may be "area", "controller", "action", and custom parameters that are
You may suppress this error message by calling an overload of the RouteValues.Add() or RouteValues.AddRange() that accepts the 'throwIfReservedKey' argument and passing false for the value. Note that if you do this, attempting to add a key with a reserved name to the RouteValues dictionary will silently fail.
+
+ The dynamic node provider instance named '{0}' was not found. Check your DI configuration to ensure a dynamic node provider instance with this name exists and is configured correctly.
+
\ No newline at end of file
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs
index 37a4a2ce..fe4d4dee 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMap.cs
@@ -816,8 +816,8 @@ protected virtual ISiteMapNode ReturnNodeIfAccessible(ISiteMapNode node)
protected virtual bool UsesDefaultUrlResolver(ISiteMapNode node)
{
- return string.IsNullOrEmpty(node.UrlResolver) ||
- node.UrlResolver.Equals(typeof(MvcSiteMapProvider.Web.UrlResolver.SiteMapNodeUrlResolver).ShortAssemblyQualifiedName(), StringComparison.InvariantCulture);
+ return string.IsNullOrEmpty(node.UrlResolver) ||
+ typeof(MvcSiteMapProvider.Web.UrlResolver.SiteMapNodeUrlResolver).Equals(Type.GetType(node.UrlResolver, false));
}
protected virtual void AssertSiteMapNodeConfigurationIsValid(ISiteMapNode node)
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderBase.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderBase.cs
index e3b4a1b1..4c13247d 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderBase.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderBase.cs
@@ -16,7 +16,7 @@ public abstract class SiteMapNodeVisibilityProviderBase
/// Determines whether the node is visible. Override this member to provide alternate implementations of VisibilityProvider.
///
/// The node.
- /// The source metadata.
+ /// The source meta-data.
///
/// true if the specified node is visible; otherwise, false.
///
@@ -25,13 +25,16 @@ public abstract class SiteMapNodeVisibilityProviderBase
///
/// Determines whether the provider instance matches the name
///
- /// The name of the visibiltiy provider. This can be any string, but for backward compatibility the type name can be used.
+ /// The name of the visibility provider. This can be any string, but for backward compatibility the type name is used.
///
/// true if the provider name matches; otherwise false.
///
public virtual bool AppliesTo(string providerName)
{
- return this.GetType().ShortAssemblyQualifiedName().Equals(providerName, StringComparison.InvariantCulture);
+ if (string.IsNullOrEmpty(providerName))
+ return false;
+
+ return this.GetType().Equals(Type.GetType(providerName, false));
}
#endregion
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderStrategy.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderStrategy.cs
index 68c33e88..c28f6f98 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderStrategy.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNodeVisibilityProviderStrategy.cs
@@ -6,7 +6,7 @@ namespace MvcSiteMapProvider
{
///
/// Tracks all of the registered instances of and
- /// allows the caller to get a specific named instance of this interface at runtime.
+ /// allows the caller to get a specific named instance of at runtime.
///
public class SiteMapNodeVisibilityProviderStrategy
: ISiteMapNodeVisibilityProviderStrategy
@@ -28,27 +28,25 @@ public SiteMapNodeVisibilityProviderStrategy(ISiteMapNodeVisibilityProvider[] si
public ISiteMapNodeVisibilityProvider GetProvider(string providerName)
{
- ISiteMapNodeVisibilityProvider provider = null;
- if (!String.IsNullOrEmpty(providerName))
+ if (string.IsNullOrEmpty(providerName))
{
- provider = siteMapNodeVisibilityProviders.FirstOrDefault(x => x.AppliesTo(providerName));
- if (provider == null)
- {
- throw new MvcSiteMapException(String.Format(Resources.Messages.NamedSiteMapNodeVisibilityProviderNotFound, providerName));
- }
+ // Get the configured default provider
+ providerName = this.defaultProviderName;
}
- else if (!string.IsNullOrEmpty(defaultProviderName))
+
+ var provider = this.siteMapNodeVisibilityProviders.FirstOrDefault(x => x.AppliesTo(providerName));
+ if (provider == null && !string.IsNullOrEmpty(providerName))
{
- // Return the configured default provider
- provider = siteMapNodeVisibilityProviders.FirstOrDefault(x => x.AppliesTo(defaultProviderName));
+ throw new MvcSiteMapException(string.Format(Resources.Messages.NamedSiteMapNodeVisibilityProviderNotFound, providerName));
}
+
return provider;
}
public bool IsVisible(string providerName, ISiteMapNode node, IDictionary sourceMetadata)
{
- var provider = GetProvider(providerName);
- if (provider == null) return true; // If no default provider configured, then always visible.
+ var provider = this.GetProvider(providerName);
+ if (provider == null) return true; // If no provider configured, then always visible.
return provider.IsVisible(node, sourceMetadata);
}
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverBase.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverBase.cs
index ca90b82f..730436a6 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverBase.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverBase.cs
@@ -27,13 +27,16 @@ public abstract class SiteMapNodeUrlResolverBase
///
/// Determines whether the provider instance matches the name
///
- /// The name of the URL resolver. This can be any string, but for backward compatibility the type name can be used.
+ /// The name of the URL resolver. This can be any string, but for backward compatibility the type name is used.
///
/// true if the provider name matches; otherwise false.
///
public virtual bool AppliesTo(string providerName)
{
- return this.GetType().ShortAssemblyQualifiedName().Equals(providerName, StringComparison.InvariantCulture);
+ if (string.IsNullOrEmpty(providerName))
+ return false;
+
+ return this.GetType().Equals(Type.GetType(providerName, false));
}
#endregion
diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverStrategy.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverStrategy.cs
index d887f756..97d480bd 100644
--- a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverStrategy.cs
+++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/UrlResolver/SiteMapNodeUrlResolverStrategy.cs
@@ -6,8 +6,8 @@
namespace MvcSiteMapProvider.Web.UrlResolver
{
///
- /// Tracks all of the registered instances of and
- /// allows the caller to get a specific named instance of this interface at runtime.
+ /// Tracks all of the registered instances of and
+ /// allows the caller to get a specific named instance of at runtime.
///
public class SiteMapNodeUrlResolverStrategy
: ISiteMapNodeUrlResolverStrategy
@@ -26,22 +26,22 @@ public SiteMapNodeUrlResolverStrategy(ISiteMapNodeUrlResolver[] siteMapUrlResolv
public ISiteMapNodeUrlResolver GetProvider(string providerName)
{
- var provider = siteMapUrlResolvers.FirstOrDefault(x => x.AppliesTo(providerName));
+ var provider = this.siteMapUrlResolvers.FirstOrDefault(x => x.AppliesTo(providerName));
if (provider == null)
{
- if (!String.IsNullOrEmpty(providerName) && !providerName.Equals("default", StringComparison.InvariantCultureIgnoreCase))
+ if (!string.IsNullOrEmpty(providerName))
{
- throw new MvcSiteMapException(String.Format(Resources.Messages.NamedUrlResolverNotFound, providerName));
+ throw new MvcSiteMapException(string.Format(Resources.Messages.NamedUrlResolverNotFound, providerName));
}
- // Return the SiteMapNodeUrlResolver type by default if the requested type is empty string or "default".
- provider = siteMapUrlResolvers.FirstOrDefault(x => x.GetType().Equals(typeof(SiteMapNodeUrlResolver)));
+ // Return the SiteMapNodeUrlResolver type by default if the requested type is empty string.
+ provider = this.siteMapUrlResolvers.FirstOrDefault(x => x.GetType().Equals(typeof(SiteMapNodeUrlResolver)));
}
return provider;
}
public string ResolveUrl(string providerName, ISiteMapNode node, string area, string controller, string action, IDictionary routeValues)
{
- var provider = GetProvider(providerName);
+ var provider = this.GetProvider(providerName);
if (provider == null) return string.Empty;
return provider.ResolveUrl(node, area, controller, action, routeValues);
}