/// <summary> /// Reads an object from current xml node. /// </summary> /// <returns>The object.</returns> /// <remarks> /// This method creates an instance of object described by the current xml node, then invokes /// its <b>Deserialize</b> method. /// </remarks> /// <example>This example demonstrates the use of <b>ReadProperties</b>, <b>ReadChildren</b>, /// <b>NextItem</b>, <b>Read</b> methods. /// <code> /// public void Deserialize(FRReader reader) /// { /// // read simple properties like "Text", complex properties like "Border.Lines" /// reader.ReadProperties(this); /// /// // moves the current reader item /// while (reader.NextItem()) /// { /// // read the "Styles" collection /// if (String.Compare(reader.ItemName, "Styles", true) == 0) /// reader.Read(Styles); /// else if (reader.ReadChildren) /// { /// // if read of children is enabled, read them /// Base obj = reader.Read(); /// if (obj != null) /// obj.Parent = this; /// } /// } /// } /// </code> /// </example> public IFRSerializable Read() { XmlItem saveCurItem = curItem; XmlItem saveCurRoot = curRoot; XmlProperty[] saveProps = props; IFRSerializable result = null; try { if (curItem == null) { curItem = root; } curRoot = curItem; GetProps(); if (report != null && report.IsAncestor) { result = report.FindObject(ReadStr("Name")); } if (result == null && curItem.Name != "inherited") { Type type = RegisteredObjects.FindType(curItem.Name); if (type != null) { result = Activator.CreateInstance(type) as IFRSerializable; if (result is Report) { report = result as Report; } } else { if (!Config.WebMode) { MessageBox.Show(Res.Get("Messages,CantFindObject") + " " + curItem.Name); } else { throw new ClassException(curItem.Name); } } } if (result != null) { result.Deserialize(this); } } finally { curItem = saveCurItem; curRoot = saveCurRoot; props = saveProps; } return(result); }
/// <summary> /// Reads an object from current xml node. /// </summary> /// <returns>The object.</returns> /// <remarks> /// This method creates an instance of object described by the current xml node, then invokes /// its <b>Deserialize</b> method. /// </remarks> /// <example>This example demonstrates the use of <b>ReadProperties</b>, <b>ReadChildren</b>, /// <b>NextItem</b>, <b>Read</b> methods. /// <code> /// public void Deserialize(FRReader reader) /// { /// // read simple properties like "Text", complex properties like "Border.Lines" /// reader.ReadProperties(this); /// /// // moves the current reader item /// while (reader.NextItem()) /// { /// // read the "Styles" collection /// if (String.Compare(reader.ItemName, "Styles", true) == 0) /// reader.Read(Styles); /// else if (reader.ReadChildren) /// { /// // if read of children is enabled, read them /// Base obj = reader.Read(); /// if (obj != null) /// obj.Parent = this; /// } /// } /// } /// </code> /// </example> public IFRSerializable Read() { XmlItem saveCurItem = FCurItem; XmlItem saveCurRoot = FCurRoot; List <PropInfo> saveProps = FProps; IFRSerializable result = null; try { if (FCurItem == null) { FCurItem = FRoot; } FCurRoot = FCurItem; GetProps(); if (FReport != null && FReport.IsAncestor) { result = FReport.FindObject(ReadStr("Name")); } if (result == null && FCurItem.Name != "inherited") { Type type = RegisteredObjects.FindType(FCurItem.Name); if (type != null) { result = Activator.CreateInstance(type) as IFRSerializable; if (result is Report) { FReport = result as Report; } } else { throw new ClassException(FCurItem.Name); } } if (result != null) { result.Deserialize(this); } } finally { FCurItem = saveCurItem; FCurRoot = saveCurRoot; FProps = saveProps; } return(result); }