Write() public method

This write method will serialize the contents of the provided object to the given XML element. This will use the String.valueOf method to convert the object to a string if the object represents a primitive, if however the object represents an enumerated type then the text value is created using Enum.name.
public Write ( OutputNode node, Object source ) : void
node OutputNode /// this is the XML element to have its text set ///
source Object /// this is the object to be serialized ///
return void
コード例 #1
0
ファイル: PrimitiveArray.cs プロジェクト: restlet/simplexml
        /// <summary>
        /// This <c>write</c> method will write the specified object
        /// to the given XML element as as array entries. Each entry within
        /// the given array must be assignable to the array component type.
        /// This will deserialize each entry type as a primitive value. In
        /// order to do this the parent string provided forms the element.
        /// </summary>
        /// <param name="source">
        /// this is the source object array to be serialized
        /// </param>
        /// <param name="node">
        /// this is the XML element container to be populated
        /// </param>
        /// <param name="index">
        /// this is the position in the array to set the item
        /// </param>
        public void Write(OutputNode node, Object source, int index)
        {
            Object item = Array.get(source, index);

            if (item != null)
            {
                if (!IsOverridden(node, item))
                {
                    root.Write(node, item);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// This <c>write</c> method will write the specified object
        /// to the given XML element as as list entries. Each entry within
        /// the given list must be assignable to the given primitive type.
        /// This will deserialize each entry type as a primitive value. In
        /// order to do this the parent string provided forms the element.
        /// </summary>
        /// <param name="source">
        /// this is the source object array to be serialized
        /// </param>
        /// <param name="node">
        /// this is the XML element container to be populated
        /// </param>
        public void Write(OutputNode node, Object source)
        {
            Collection list = (Collection)source;

            for (Object item : list)
            {
                if (item != null)
                {
                    OutputNode child = node.getChild(parent);
                    if (!IsOverridden(child, item))
                    {
                        root.Write(child, item);
                    }
                }
            }
        }
コード例 #3
0
ファイル: PrimitiveValue.cs プロジェクト: restlet/simplexml
        /// <summary>
        /// This method is used to write the value to the specified node.
        /// The value written to the node can be an attribute or an element
        /// depending on the annotation attribute values. This method will
        /// maintain references for serialized elements.
        /// </summary>
        /// <param name="node">
        /// this is the node that the value is written to
        /// </param>
        /// <param name="item">
        /// this is the item that is to be written
        /// </param>
        /// <param name="key">
        /// this is the name of the node to be created
        /// </param>
        public void Write(OutputNode node, Object item, String key)
        {
            String name = style.GetAttribute(key);

            if (!entry.IsInline())
            {
                node = node.getChild(name);
            }
            if (item != null)
            {
                if (!IsOverridden(node, item))
                {
                    root.Write(node, item);
                }
            }
        }
コード例 #4
0
ファイル: PrimitiveKey.cs プロジェクト: restlet/simplexml
        /// <summary>
        /// This method is used to write the value to the specified node.
        /// This will write the item as an element to the provided node,
        /// also this enables references to be used during serialization.
        /// </summary>
        /// <param name="node">
        /// this is the node that the value is written to
        /// </param>
        /// <param name="item">
        /// this is the item that is to be written
        /// </param>
        public void WriteElement(OutputNode node, Object item)
        {
            Class  expect = type.Type;
            String key    = entry.Key;

            if (key == null)
            {
                key = context.GetName(expect);
            }
            String     name  = style.GetElement(key);
            OutputNode child = node.getChild(name);

            if (item != null)
            {
                if (!IsOverridden(child, item))
                {
                    root.Write(child, item);
                }
            }
        }