/// Resolve collection property and node for the current XML node. Exception is thrown if nothing is found. protected void ResolveCollectionAndTypeForNode(XmlReader reader, IXsContext context, out PropertyInfo collection, out Type type) { foreach (PropertyInfo c in GetType().GetProperties()) { foreach (XsElementAttribute e in CustomAttributeHelper.All <XsElementAttribute>(c)) { if (e.Name.Length == 0 && (string.IsNullOrEmpty(e.CollectionItemElementName) || string.Compare(e.CollectionItemElementName, reader.LocalName, StringComparison.OrdinalIgnoreCase) == 0)) { collection = c; type = e.CollectionItemType; if (context != null && (type == null || type.IsInterface || type.IsAbstract)) { type = context.ResolveType(reader); } if (type == null || type.IsInterface || type.IsAbstract) { continue; } return; } } } collection = null; type = null; throw new XsException(reader, string.Format("Unknown xml element '{0}'", reader.Name)); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected virtual void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo setToProperty) { Type t; PropertyInfo collProperty = null; if (setToProperty != null) { t = setToProperty.PropertyType; } else { ResolveCollectionAndTypeForNode(reader, context, out collProperty, out t); } object newObject = Utils.CreateInstance(t); IXsElement xse = newObject as IXsElement; if (xse != null) { xse.ReadXml(context, reader); } else { reader.Skip(); } SetChildObject(reader, newObject, setToProperty, collProperty); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="property">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo property) { if (Value != null) { throw new ParsingException("Multiple root elements in xmldoc value are not allowed"); } Value = reader.ReadOuterXml(); }
/// <summary> /// Read element from the XML reader /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> public override void ReadXml(IXsContext context, XmlReader reader) { base.ReadXml(context, reader); if (WithTypes) { Initialize(); } }
/// <summary> /// Called when XML Reader reads an attribute or a text field /// </summary> /// <param name="context">Context</param> /// <param name="attribute">Attribute name, or an empty string for element text</param> /// <param name="value">Attribute value</param> /// <param name="previouslyProcessed">List of previously processed attributes, to detect duplicate attributes. May be null if duplicate attributes are allowed.</param> /// <returns>true, if the attribute if correctly processed and false otherwise</returns> protected override bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary <string, bool> previouslyProcessed) { if (previouslyProcessed != null && !string.IsNullOrEmpty(attribute)) { previouslyProcessed.Add(attribute, true); } _variables[attribute ?? string.Empty] = value; return(true); }
/// <summary> /// Read element from the XML reader /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> public override void ReadXml(IXsContext context, XmlReader reader) { base.ReadXml(context, reader); if (WithTypes) { ScriptContext c = (ScriptContext)context; c.AddAssembly(AddReference(c, true), true); } }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, System.Reflection.PropertyInfo setToProperty) { if (reader.LocalName == "Signature") { XmlSignature = reader.ReadOuterXml(); } else { base.ReadChildElement(context, reader, setToProperty); } }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, System.Xml.XmlReader reader, System.Reflection.PropertyInfo setToProperty) { int itemsBefore = Items.Count; base.ReadChildElement(context, reader, setToProperty); if (Items.Count != itemsBefore && (Try != null || Catch != null || Finally != null)) { throw new XsException(reader, "actions after try block are NOT allowed!"); } }
protected override bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary<string, bool> previouslyProcessed) { if (!base.ProcessAttribute(context, attribute, value, previouslyProcessed)) { if (Name != null) throw new ParsingException("Only a single variable may be set by using action."); Name = attribute; Value = value; if (previouslyProcessed != null && !string.IsNullOrEmpty(attribute)) previouslyProcessed.Add(attribute, true); } return true; }
internal void RunWithTypes(IXsContext context) { if (WithTypes) { Initialize(); ScriptContext c = (ScriptContext)context; c.Compiler.AddHeaders(GetTransformedValueStr()); Code code = new Code(); c.Initialize(code); Assembly a = c.GetClassInstanceType(code).Assembly; c.AddAssembly(a, true); } }
/// <summary> /// Read element from the XML reader /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> public virtual void ReadXml(IXsContext context, XmlReader reader) { reader.MoveToContent(); int startDepth = reader.Depth; if (reader.HasAttributes) { Dictionary <string, bool> attr = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase); try { while (reader.MoveToNextAttribute()) { if (!string.IsNullOrEmpty(reader.NamespaceURI)) { continue; } if (!ProcessAttribute(context, reader.LocalName, reader.Value, attr)) { throw new XsException(reader, string.Format("Unknown attribute '{0}'", reader.Name)); } } } catch (Exception e) { if (!(e is XsException)) { throw new XsException(reader, string.Format("Failed to process attribute '{0}'", reader.Name), e); } throw; } reader.MoveToElement(); } if (reader.IsEmptyElement) { reader.Read(); return; } reader.ReadStartElement(); while (reader.Depth > startDepth && reader.NodeType != XmlNodeType.EndElement) { ProcessInnerNode(context, reader); } reader.ReadEndElement(); }
/// <summary> /// Called when XML Reader reads an attribute or a text field /// </summary> /// <param name="context">Context</param> /// <param name="attribute">Attribute name, or an empty string for element text</param> /// <param name="value">Attribute value</param> /// <param name="previouslyProcessed">List of previously processed attributes, to detect duplicate attributes. May be null if duplicate attributes are allowed.</param> /// <returns> true, if the attribute if correctly processed and false otherwise </returns> protected override bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary <string, bool> previouslyProcessed) { if (!base.ProcessAttribute(context, attribute, value, previouslyProcessed)) { var c = new CallParam(); c.Name = attribute; c.Value = value; c.Transform = Transform; Parameters.Add(c); if (previouslyProcessed != null && !string.IsNullOrEmpty(attribute)) { previouslyProcessed.Add(attribute, true); } } return(true); }
protected override bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary <string, bool> previouslyProcessed) { if (!base.ProcessAttribute(context, attribute, value, previouslyProcessed)) { if (Name != null) { throw new ParsingException("Only a single variable may be set by using action."); } Name = attribute; Value = value; if (previouslyProcessed != null && !string.IsNullOrEmpty(attribute)) { previouslyProcessed.Add(attribute, true); } } return(true); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo setToProperty) { string name = reader.LocalName; var v = reader.GetAttribute("_xml"); string value; if (v != null && Utils.To <bool>(v)) { value = reader.ReadInnerXml(); } else { value = reader.ReadElementContentAsString(); } _variables.Add(new Var(name, value)); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, System.Xml.XmlReader reader, System.Reflection.PropertyInfo setToProperty) { if (string.Compare(reader.LocalName, "else", StringComparison.OrdinalIgnoreCase) == 0) { if (Else != null) { throw new ParsingException("Only one else block is allowed per if statement!"); } // To allow special <if> <else /> </if> syntax if (reader.IsEmptyElement) { Else = new Block(); reader.Skip(); return; } } base.ReadChildElement(context, reader, setToProperty); }
/// <summary> /// Process inner node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> protected virtual void ProcessInnerNode(IXsContext context, XmlReader reader) { switch (reader.NodeType) { case XmlNodeType.Element: ReadChildElement(context, reader, FindRelatedProperty(reader)); break; case XmlNodeType.Text: case XmlNodeType.CDATA: if (!ProcessAttribute(context, string.Empty, reader.Value, null)) { throw new XsException(reader, string.Format("Element '{0}' cannot have text", ToString())); } reader.Read(); break; default: reader.Read(); break; } }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo setToProperty) { Type t; if (setToProperty != null) { t = setToProperty.PropertyType; } else { t = (context == null)?null:context.ResolveType(reader); } if (t == null) { throw new XsException(reader, string.Format("Unknown xml element '{0}'", reader.Name)); } object newObject = Utils.CreateInstance(t); IXsElement xse = newObject as IXsElement; if (xse != null) { xse.ReadXml(context, reader); } else { reader.Skip(); } if (setToProperty != null) { SetChildObject(reader, newObject, setToProperty, null); } else { Add((IScriptAction)newObject); } }
/// <summary> /// Called when XML Reader reads an attribute or a text field /// </summary> /// <param name="context">Context</param> /// <param name="attribute">Attribute name, or an empty string for element text</param> /// <param name="value">Attribute value</param> /// <param name="previouslyProcessed">List of previously processed attributes, to detect duplicate attributes. May be null if duplicate attributes are allowed.</param> /// <returns>true, if the attribute if correctly processed and false otherwise</returns> protected virtual bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary <string, bool> previouslyProcessed) { if (string.IsNullOrEmpty(attribute)) { return(processText(value)); } bool proc = false; foreach (PropertyInfo c in GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty)) { var n = XsAttributeAttribute.GetNames(c, true); if (n == null) { continue; } foreach (var s in n) { if (string.Compare(s, attribute, StringComparison.OrdinalIgnoreCase) == 0) { SetValue(c, value); proc = true; } // Check that we aren't setting the same value twice if (previouslyProcessed != null && proc && !string.IsNullOrEmpty(attribute)) { previouslyProcessed.Add(s, true); } } if (proc) { break; } } return(proc); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, System.Reflection.PropertyInfo setToProperty) { if (reader.LocalName == "Signature") XmlSignature=reader.ReadOuterXml(); else base.ReadChildElement(context, reader, setToProperty); }
/// <summary> /// Process inner node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> protected override void ProcessInnerNode(IXsContext context, XmlReader reader) { PropertyInfo collProperty = null; switch (reader.NodeType) { case XmlNodeType.Comment: collProperty = FindCollectionForNode(reader); if (collProperty != null) { SetChildObject(reader, new Rem(reader.Value), null, collProperty); } reader.Read(); break; case XmlNodeType.ProcessingInstruction: IScriptAction a = null; if (string.Compare(reader.LocalName, "_", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "code", StringComparison.OrdinalIgnoreCase) == 0) { a = new Code(reader.Value); } else if (string.Compare(reader.LocalName, "_d", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "codeD", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "codeDynamic", StringComparison.OrdinalIgnoreCase) == 0) { a = new Code(reader.Value) { Dynamic = true } } ; else if (string.Compare(reader.LocalName, "header", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "h", StringComparison.OrdinalIgnoreCase) == 0) { a = new Header(reader.Value); } else if (string.Compare(reader.LocalName, "headerWithTypes", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "ht", StringComparison.OrdinalIgnoreCase) == 0) { var h = new Header(reader.Value) { WithTypes = true }; h.RunWithTypes(context); a = h; } else if (string.Compare(reader.LocalName, "rem", StringComparison.OrdinalIgnoreCase) == 0) { a = new Rem { Text = reader.Value } } ; else if (string.Compare(reader.LocalName, "xsharper-args", StringComparison.OrdinalIgnoreCase) == 0) { reader.Read(); break; } if (a == null) { throw new XsException(reader, string.Format("Unexpected processing instruction {0}", reader.Name)); } if (this is Code) { if (a is Code) { ProcessAttribute(context, string.Empty, reader.Value, null); } else { ((Code)this).Add(a); } } else { collProperty = FindCollectionForNode(reader); try { SetChildObject(reader, a, null, collProperty); } catch (XsException) { if (!(a is Rem)) { throw; } } } // coll.Add(a); reader.Read(); break; default: base.ProcessInnerNode(context, reader); break; } }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, System.Xml.XmlReader reader, System.Reflection.PropertyInfo setToProperty) { if (string.Compare(reader.LocalName, "else", StringComparison.OrdinalIgnoreCase) == 0) { if (Else!=null) throw new ParsingException("Only one else block is allowed per if statement!"); // To allow special <if> <else /> </if> syntax if (reader.IsEmptyElement) { Else = new Block(); reader.Skip(); return; } } base.ReadChildElement(context, reader, setToProperty); }
internal void RunWithTypes(IXsContext context) { if (WithTypes) { Initialize(); ScriptContext c = (ScriptContext) context; c.Compiler.AddHeaders(GetTransformedValueStr()); Code code = new Code(); c.Initialize(code); Assembly a = c.GetClassInstanceType(code).Assembly; c.AddAssembly(a,true); } }
/// Resolve collection property and node for the current XML node. Exception is thrown if nothing is found. protected void ResolveCollectionAndTypeForNode(XmlReader reader, IXsContext context, out PropertyInfo collection, out Type type) { foreach (PropertyInfo c in GetType().GetProperties()) foreach (XsElementAttribute e in CustomAttributeHelper.All<XsElementAttribute>(c)) if (e.Name.Length==0 && (string.IsNullOrEmpty(e.CollectionItemElementName) || string.Compare(e.CollectionItemElementName,reader.LocalName,StringComparison.OrdinalIgnoreCase)==0)) { collection = c; type = e.CollectionItemType; if (context!=null && (type == null || type.IsInterface || type.IsAbstract)) type = context.ResolveType(reader); if (type == null || type.IsInterface || type.IsAbstract) continue; return; } collection = null; type = null; throw new XsException(reader, string.Format("Unknown xml element '{0}'", reader.Name)); }
/// <summary> /// Process inner node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> protected virtual void ProcessInnerNode(IXsContext context, XmlReader reader) { switch (reader.NodeType) { case XmlNodeType.Element: ReadChildElement(context, reader, FindRelatedProperty(reader)); break; case XmlNodeType.Text: case XmlNodeType.CDATA: if (!ProcessAttribute(context, string.Empty, reader.Value,null)) throw new XsException(reader, string.Format("Element '{0}' cannot have text", ToString())); reader.Read(); break; default: reader.Read(); break; } }
/// <summary> /// Read element from the XML reader /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> public virtual void ReadXml(IXsContext context, XmlReader reader) { reader.MoveToContent(); int startDepth = reader.Depth; if (reader.HasAttributes) { Dictionary<string, bool> attr = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); try { while (reader.MoveToNextAttribute()) { if (!string.IsNullOrEmpty(reader.NamespaceURI)) continue; if (!ProcessAttribute(context, reader.LocalName, reader.Value, attr)) throw new XsException(reader, string.Format("Unknown attribute '{0}'", reader.Name)); } } catch (Exception e) { if (!(e is XsException)) throw new XsException(reader, string.Format("Failed to process attribute '{0}'", reader.Name), e); throw; } reader.MoveToElement(); } if (reader.IsEmptyElement) { reader.Read(); return; } reader.ReadStartElement(); while (reader.Depth > startDepth && reader.NodeType != XmlNodeType.EndElement) { ProcessInnerNode(context, reader); } reader.ReadEndElement(); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, System.Xml.XmlReader reader, System.Reflection.PropertyInfo setToProperty) { int itemsBefore = Items.Count; base.ReadChildElement(context, reader, setToProperty); if (Items.Count!=itemsBefore && (Try != null || Catch != null || Finally != null)) throw new XsException(reader, "actions after try block are NOT allowed!"); }
/// Where is a simplification really protected override void ReadChildElement(IXsContext context, XmlReader reader, System.Reflection.PropertyInfo setToProperty) { throw new XsException(reader, "where clause cannot have any child elements"); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="property">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo property) { if (Value!=null) throw new ParsingException("Multiple root elements in xmldoc value are not allowed"); Value= reader.ReadOuterXml(); }
/// <summary> /// Called when XML Reader reads an attribute or a text field /// </summary> /// <param name="context">Context</param> /// <param name="attribute">Attribute name, or an empty string for element text</param> /// <param name="value">Attribute value</param> /// <param name="previouslyProcessed">List of previously processed attributes, to detect duplicate attributes. May be null if duplicate attributes are allowed.</param> /// <returns> true, if the attribute if correctly processed and false otherwise </returns> protected override bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary<string, bool> previouslyProcessed) { if (!base.ProcessAttribute(context, attribute, value, previouslyProcessed)) { var c=new CallParam(); c.Name=attribute; c.Value=value; c.Transform=Transform; Parameters.Add(c); if (previouslyProcessed != null && !string.IsNullOrEmpty(attribute)) previouslyProcessed.Add(attribute, true); } return true; }
/// <summary> /// Called when XML Reader reads an attribute or a text field /// </summary> /// <param name="context">Context</param> /// <param name="attribute">Attribute name, or an empty string for element text</param> /// <param name="value">Attribute value</param> /// <param name="previouslyProcessed">List of previously processed attributes, to detect duplicate attributes. May be null if duplicate attributes are allowed.</param> /// <returns>true, if the attribute if correctly processed and false otherwise</returns> protected virtual bool ProcessAttribute(IXsContext context, string attribute, string value, IDictionary<string,bool> previouslyProcessed) { if (string.IsNullOrEmpty(attribute)) return processText(value); bool proc = false; foreach (PropertyInfo c in GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty)) { var n = XsAttributeAttribute.GetNames(c,true); if (n==null) continue; foreach (var s in n) { if (string.Compare(s, attribute, StringComparison.OrdinalIgnoreCase) == 0) { SetValue(c, value); proc=true; } // Check that we aren't setting the same value twice if (previouslyProcessed != null && proc && !string.IsNullOrEmpty(attribute)) previouslyProcessed.Add(s, true); } if (proc) break; } return proc; }
/// <summary> /// Process inner node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> protected override void ProcessInnerNode(IXsContext context, XmlReader reader) { PropertyInfo collProperty = null; switch (reader.NodeType) { case XmlNodeType.Comment: collProperty = FindCollectionForNode(reader); if (collProperty != null) SetChildObject(reader, new Rem(reader.Value), null, collProperty); reader.Read(); break; case XmlNodeType.ProcessingInstruction: IScriptAction a = null; if (string.Compare(reader.LocalName, "_", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "code", StringComparison.OrdinalIgnoreCase) == 0) a = new Code(reader.Value); else if (string.Compare(reader.LocalName, "_d", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "codeD", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "codeDynamic", StringComparison.OrdinalIgnoreCase) == 0) a = new Code(reader.Value) {Dynamic = true}; else if (string.Compare(reader.LocalName, "header", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "h", StringComparison.OrdinalIgnoreCase) == 0) a = new Header(reader.Value); else if (string.Compare(reader.LocalName, "headerWithTypes", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(reader.LocalName, "ht", StringComparison.OrdinalIgnoreCase) == 0) { var h = new Header(reader.Value) {WithTypes = true}; h.RunWithTypes(context); a = h; } else if (string.Compare(reader.LocalName, "rem", StringComparison.OrdinalIgnoreCase) == 0) a = new Rem { Text = reader.Value }; else if (string.Compare(reader.LocalName, "xsharper-args", StringComparison.OrdinalIgnoreCase) == 0) { reader.Read(); break; } if (a == null) throw new XsException(reader, string.Format("Unexpected processing instruction {0}", reader.Name)); if (this is Code) { if (a is Code) ProcessAttribute(context, string.Empty, reader.Value, null); else ((Code) this).Add(a); } else { collProperty = FindCollectionForNode(reader); try { SetChildObject(reader, a, null, collProperty); } catch (XsException) { if (!(a is Rem)) throw; } } // coll.Add(a); reader.Read(); break; default: base.ProcessInnerNode(context, reader); break; } }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected virtual void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo setToProperty) { Type t; PropertyInfo collProperty = null; if (setToProperty != null) t = setToProperty.PropertyType; else ResolveCollectionAndTypeForNode(reader, context, out collProperty, out t); object newObject = Utils.CreateInstance(t); IXsElement xse = newObject as IXsElement; if (xse != null) xse.ReadXml(context, reader); else reader.Skip(); SetChildObject(reader, newObject, setToProperty, collProperty); }
/// <summary> /// Read element from the XML reader /// </summary> /// <param name="context">XML context</param> /// <param name="reader">Reader</param> public override void ReadXml(IXsContext context, XmlReader reader) { base.ReadXml(context, reader); RunWithTypes(context); }
/// <summary> /// Read child element of the current node /// </summary> /// <param name="context">XML context</param> /// <param name="reader">XML reader</param> /// <param name="setToProperty">Property to which the object must be assigned, or null for automatic resolution</param> protected override void ReadChildElement(IXsContext context, XmlReader reader, PropertyInfo setToProperty) { Type t; if (setToProperty != null) t = setToProperty.PropertyType; else t = (context==null)?null:context.ResolveType(reader); if (t==null) throw new XsException(reader, string.Format("Unknown xml element '{0}'", reader.Name)); object newObject = Utils.CreateInstance(t); IXsElement xse = newObject as IXsElement; if (xse != null) xse.ReadXml(context, reader); else reader.Skip(); if (setToProperty != null) SetChildObject(reader, newObject, setToProperty, null); else Add((IScriptAction) newObject); }