Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }