Exemplo n.º 1
0
		/// <summary>
		/// Converts the object passed in to its XML representation.
		/// The XML string is written on the XmlTextWriter.
		/// </summary>
		public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context)
		{
			Array array				= value as Array;
			Type arrayType			= array.GetType();

			context.WriteStartTag( arrayType, field, xml );
			
			int stackIx	= context.GetStackIndex( value );

			if ( stackIx >= 0 )
				xml.WriteAttributeString( "ref", stackIx.ToString() );
			else
			{
				context.Stack( array );

				foreach ( object child in array )
				{
					IConverter converter;

					if ( child != null )
						converter = context.GetConverter( child.GetType() );
					else
						converter = context.GetConverter( null );

                    if (converter == null) throw new ConversionException("Couldnot find converter for: " + child.GetType() + " having value: " + child);
					converter.ToXml( child, null, xml, context );
				}
			}

			context.WriteEndTag( arrayType, field, xml );
		}
Exemplo n.º 2
0
        private void WriteAfterStartTag(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context, Type type)
        {
            int stackIx = context.GetStackIndex(value);

            if (stackIx >= 0)
                xml.WriteAttributeString("ref", stackIx.ToString());
            else
            {
                context.Stack(value, type);

                if (value != null)
                    ToXmlAs(context, type, value, xml);
            }

            context.WriteEndTag(type, field, xml);
        }
Exemplo n.º 3
0
        private void WriteAfterStartTag(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context, Type type)
        {
            int stackIx = context.GetStackIndex(value);

            if (stackIx >= 0)
            {
                xml.WriteAttributeString("ref", stackIx.ToString());
            }
            else
            {
                context.Stack(value, type);

                if (value != null)
                {
                    ToXmlAs(context, type, value, xml);
                }
            }

            context.WriteEndTag(type, field, xml);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts the object passed in to its XML representation.
        /// The XML string is written on the XmlTextWriter.
        /// </summary>
        public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context)
        {
            Array array     = value as Array;
            Type  arrayType = array.GetType();

            context.WriteStartTag(arrayType, field, xml);

            int stackIx = context.GetStackIndex(value);

            if (stackIx >= 0)
            {
                xml.WriteAttributeString("ref", stackIx.ToString());
            }
            else
            {
                context.Stack(array);

                foreach (object child in array)
                {
                    IConverter converter;

                    if (child != null)
                    {
                        converter = context.GetConverter(child.GetType());
                    }
                    else
                    {
                        converter = context.GetConverter(null);
                    }

                    if (converter == null)
                    {
                        throw new ConversionException("Couldnot find converter for: " + child.GetType() + " having value: " + child);
                    }
                    converter.ToXml(child, null, xml, context);
                }
            }

            context.WriteEndTag(arrayType, field, xml);
        }