// 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;
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 ()
parent = value;
}
}
-
+
public virtual SiteMapNodeCollection ChildNodes {
get {
- if (childNodes != null) return childNodes;
- return provider.GetChildNodes (this);
+ if (childNodes == null)
+ childNodes = provider.GetChildNodes (this);
+ return childNodes;
}
set {
CheckWritable ();
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 = reskey + "." + implicitResourceKey + "." + attributeName;
- else
- reskey = String.Concat (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 (MissingManifestResourceException) {
+ } catch (MissingManifestResourceException) {
}
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;
#endregion
}
}
-#endif
+