/// <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); }
private void RegisterObject(ExportsTreeNode node, bool registerCategories) { if (node.ExportType == null && registerCategories) { RegisteredObjects.AddExportCategory(node.Name, node.ToString(), node.ImageIndex); } else if (node.ExportType != null && !registerCategories) { RegisteredObjects.AddExport(node.ExportType, node.ToString(), node.ImageIndex); } List <ObjectInfo> list = new List <ObjectInfo>(); RegisteredObjects.Objects.EnumItems(list); node.Tag = list[list.Count - 1]; }
/// <summary> /// /// </summary> public void RegisterExports() { Queue <ExportsTreeNode> queue = new Queue <ExportsTreeNode>(menuNodes); while (queue.Count != 0) { ExportsTreeNode node = queue.Dequeue(); if (node.ExportType != null) { RegisteredObjects.AddExport(node.ExportType, node.ToString(), node.ImageIndex); } List <ObjectInfo> list = new List <ObjectInfo>(); RegisteredObjects.Objects.EnumItems(list); node.Tag = list[list.Count - 1]; foreach (ExportsTreeNode nextNode in node.Nodes) { queue.Enqueue(nextNode); } } }
/// <summary> /// Gets the method or null if method is not found /// </summary> /// <param name="type">Type for method finding</param> /// <param name="methodName">Name for method finfing</param> /// <param name="inheritance">Use True value for inheritance the method from base type, use false for get the method only from the this type</param> /// <returns></returns> public static Delegate GetMethod(Type type, string methodName, bool inheritance) { if (type == typeof(object)) { return(null); } Dictionary <string, Delegate> methods; if (methodsDictionary.TryGetValue(type, out methods)) { Delegate result; if (methods.TryGetValue(methodName, out result)) { return(result); } } if (inheritance) { return(RegisteredObjects.GetMethod(type.BaseType, methodName, inheritance)); } return(null); }