Merge pull request #228 from QuickJack/3e163743eda89cc8c239779a75dd245be12aee3c
[mono.git] / mcs / class / System.XML / System.Xml / XmlEntity.cs
index 91268e6edaafd8533c0f4c1802d370901ea85446..9366805c6eab1b4a1e4c015e1c45d2294eb8b03c 100644 (file)
@@ -58,13 +58,22 @@ namespace System.Xml
                string systemId;
                string baseUri;
                XmlLinkedNode lastLinkedChild;
+               bool contentAlreadySet;
 
                #endregion
 
                #region Properties
 
                XmlLinkedNode IHasXmlChildNode.LastLinkedChild {
-                       get { return lastLinkedChild; }
+                       get {
+                               if (lastLinkedChild != null)
+                                       return lastLinkedChild;
+                               if (!contentAlreadySet) {
+                                       contentAlreadySet = true;
+                                       SetEntityContent ();
+                               }
+                               return lastLinkedChild;
+                       }
                        set { lastLinkedChild = value; }
                }
 
@@ -137,9 +146,9 @@ namespace System.Xml
                        // No effect.
                }
 
-               internal void SetEntityContent ()
+               void SetEntityContent ()
                {
-                       if (FirstChild != null)
+                       if (lastLinkedChild != null)
                                return;
 
                        XmlDocumentType doctype = OwnerDocument.DocumentType;