Merge pull request #2098 from evincarofautumn/fix-gchandle-assert
[mono.git] / mcs / class / System.Web / System.Web / SiteMapNode.cs
index d7147ac8a43facbbd16be50febdafa6212e9606d..b1660b8752c2365c8ff4981c3682921cafbd764c 100644 (file)
@@ -28,7 +28,6 @@
 // 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;
@@ -36,6 +35,7 @@ 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 {
@@ -92,7 +92,10 @@ namespace System.Web {
                }
 
                public virtual bool HasChildNodes {
-                       get { return ChildNodes != null && ChildNodes.Count != 0; }
+                       get {
+                               SiteMapNodeCollection childNodes = ChildNodes;
+                               return childNodes != null && childNodes.Count > 0;
+                       }
                }
 
                public SiteMapNodeCollection GetAllNodes ()
@@ -173,21 +176,22 @@ namespace System.Web {
                        }
                }
 
-               internal SiteMapNodeCollection ChildNodesInternal {
-                       get {
-                               if (childNodes == null)
-                                       childNodes = new SiteMapNodeCollection ();
-                               return childNodes;
-                       }
-               }
-
                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;
                        }
                }
@@ -444,9 +448,10 @@ namespace System.Web {
                string resourceKey;
                SiteMapNode parent;
                SiteMapNodeCollection childNodes;
+               IPrincipal user;
                #endregion
                
        }
 }
-#endif
+