// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
+using System.Resources;
+using System.Security.Principal;
namespace System.Web {
public class SiteMapNode : IHierarchyData, INavigateUIData, ICloneable {
- private SiteMapNode () {}
+ SiteMapNode () {}
public SiteMapNode (SiteMapProvider provider, string key)
: this (provider, key, null, null, null, null, null, null, null) {}
this.roles = roles;
this.attributes = attributes;
this.resourceKeys = explicitResourceKeys;
- this.implicitResourceKey = implicitResourceKey;
+ this.resourceKey = implicitResourceKey;
}
public SiteMapDataSourceView GetDataSourceView (SiteMapDataSource owner, string viewName)
}
public virtual bool HasChildNodes {
- get { return ChildNodes != null && ChildNodes.Count != 0; }
+ get {
+ SiteMapNodeCollection childNodes = ChildNodes;
+ return childNodes != null && childNodes.Count > 0;
+ }
}
public SiteMapNodeCollection GetAllNodes ()
void GetAllNodesRecursive(SiteMapNodeCollection c)
{
SiteMapNodeCollection childNodes = this.ChildNodes;
-
- if (childNodes.Count > 0) {
- childNodes.AddRange (childNodes);
+
+ if (childNodes != null && childNodes.Count > 0) {
+ c.AddRange (childNodes);
foreach (SiteMapNode n in childNodes)
n.GetAllNodesRecursive (c);
}
parent = value;
}
}
-
+
public virtual SiteMapNodeCollection ChildNodes {
get {
- if (childNodes != null) return childNodes;
- return provider.GetChildNodes (this);
+ if (provider.SecurityTrimmingEnabled) {
+ IPrincipal p = HttpContext.Current.User;
+ if ((user == null && user != p) || user != null && user != p) {
+ user = p;
+ childNodes = provider.GetChildNodes (this);
+ }
+ } else if (childNodes == null) {
+ childNodes = provider.GetChildNodes (this);
+ }
+ return childNodes;
}
set {
CheckWritable ();
+ user = null;
childNodes = value;
}
}
object o = HttpContext.GetGlobalResourceObject (values [0], values [1]);
if (o is string)
return (string) o;
- } catch (Exception) {
}
+ catch (MissingManifestResourceException) {
+ }
+
+ if (throwIfNotFound && defaultValue == null)
+ throw new InvalidOperationException (String.Format ("The resource object with classname '{0}' and key '{1}' was not found.", values [0], values [1]));
}
}
- if (throwIfNotFound && defaultValue == null)
- throw new InvalidOperationException ();
-
return defaultValue;
}
if (attributeName == null)
throw new ArgumentNullException ("attributeName");
- if (String.IsNullOrEmpty (implicitResourceKey))
+ string resourceKey = ResourceKey;
+ if (String.IsNullOrEmpty (resourceKey))
return null;
try {
- string reskey = provider.ResourceKey;
-
- if (!String.IsNullOrEmpty (reskey))
- reskey = String.Format ("{0}.{1}.{2}", reskey, implicitResourceKey, attributeName);
- else
- reskey = String.Format ("{0}.{1}", implicitResourceKey, attributeName);
- object o = HttpContext.GetGlobalResourceObject ("Web.sitemap", reskey);
+ object o = HttpContext.GetGlobalResourceObject (provider.ResourceKey, resourceKey + "." + attributeName);
if (o is string)
return (string) o;
- } catch (Exception) {
+ } catch (MissingManifestResourceException) {
}
return null;
public virtual string this [string key]
{
get {
- string val = null;
if (provider.EnableLocalization) {
- val = GetImplicitResourceString (key);
+ string val = GetImplicitResourceString (key);
if (val == null)
val = GetExplicitResourceString (key, null, true);
+ if (val != null)
+ return val;
}
- if (val != null) return null;
if (attributes != null) return attributes [key];
return null;
}
public string ResourceKey {
get { return resourceKey; }
- set { resourceKey = value; }
+ set {
+ if (ReadOnly)
+ throw new InvalidOperationException ("The node is read-only.");
+ resourceKey = value;
+ }
}
public string Key { get { return key; } }
bool readOnly;
string resourceKey;
SiteMapNode parent;
- string implicitResourceKey;
SiteMapNodeCollection childNodes;
+ IPrincipal user;
#endregion
}
}
-#endif
+