예제 #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 );
		}
예제 #2
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)
        {
            MethodInfo info = value as MethodInfo;

            ParameterInfo[] paramList = info.GetParameters();

            if (info.ReflectedType == null)
            {
                throw new ConversionException("Unable to serialize MethodInfo, no reflected type.");
            }

            context.WriteStartTag(__type, field, xml);

            xml.WriteElementString("base", context.GetTypeName(info.ReflectedType));
            xml.WriteElementString("name", info.Name);

            xml.WriteStartElement("params");
            foreach (ParameterInfo paramInfo in paramList)
            {
                xml.WriteElementString("param", context.GetTypeName(paramInfo.ParameterType));
            }
            xml.WriteEndElement();

            context.WriteEndTag(__type, field, xml);
        }
예제 #3
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)
		{
			Type type = value.GetType();

			context.WriteStartTag( type, field, xml );
			xml.WriteString( value.ToString() );
			context.WriteEndTag( type, field, xml );
		}
예제 #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)
        {
            Type type = value.GetType();

            context.WriteStartTag(type, field, xml);
            xml.WriteString(value.ToString());
            context.WriteEndTag(type, field, xml);
        }
예제 #5
0
        public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context)
        {
            var removedString = value.ToString().Replace("\b", "").Replace("\0", "");

            context.WriteStartTag(__type, field, xml);
            xml.WriteString(removedString);
            context.WriteEndTag(__type, field, xml);
        }
예제 #6
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)
		{
			Type type = value.GetType();

			if ( type.IsArray )
			{
				byte[] bytes = value as byte[];
				context.WriteStartTag( __arrayType, field, xml );
				xml.WriteBase64( bytes, 0, bytes.Length );
				context.WriteEndTag( __arrayType, field, xml );
			}
			else
			{
				context.WriteStartTag( __type, field, xml );
				xml.WriteString( value.ToString() );
				context.WriteEndTag( __type, field, xml );
			}
		}
예제 #7
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)
        {
            Type type = value.GetType();

            if (type.IsArray)
            {
                byte[] bytes = value as byte[];
                context.WriteStartTag(__arrayType, field, xml);
                xml.WriteBase64(bytes, 0, bytes.Length);
                context.WriteEndTag(__arrayType, field, xml);
            }
            else
            {
                context.WriteStartTag(__type, field, xml);
                xml.WriteString(value.ToString());
                context.WriteEndTag(__type, field, xml);
            }
        }
예제 #8
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)
        {
            Type type = value.GetType();

            if (value is char[])
            {
                char[] buffer = value as char[];

                context.WriteStartTag(__arrayType, field, xml);
                xml.WriteChars(buffer, 0, buffer.Length);
                context.WriteEndTag(__arrayType, field, xml);
            }
            else
            {
                context.WriteStartTag(__type, field, xml);
                xml.WriteString(value.ToString());
                context.WriteEndTag(__type, field, xml);
            }
        }
예제 #9
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)
		{
			Type type = value.GetType();

			if ( value is char[] )
			{
				char[] buffer = value as char[];

				context.WriteStartTag( __arrayType, field, xml );
				xml.WriteChars( buffer, 0, buffer.Length );
				context.WriteEndTag( __arrayType, field, xml );
			}
			else
			{
				context.WriteStartTag( __type, field, xml );
				xml.WriteString( value.ToString() );
				context.WriteEndTag( __type, field, xml );
			}
		}
예제 #10
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)
        {
            Type type = value != null ? value.GetType() : null;

            if (typeof (MulticastDelegate).IsAssignableFrom(type))
                return;

            // If dynamic type, use the base type instead
            if (type.ToString().StartsWith(DynamicInstanceBuilder.__typePrefix))
                type = type.BaseType;

            context.WriteStartTag(type, field, xml);
            WriteAfterStartTag(value, field, xml, context, type);
        }
예제 #11
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)
        {
            Type type = value != null?value.GetType() : null;

            if (typeof(MulticastDelegate).IsAssignableFrom(type))
            {
                return;
            }

            // If dynamic type, use the base type instead
            if (type.ToString().StartsWith(DynamicInstanceBuilder.__typePrefix))
            {
                type = type.BaseType;
            }

            context.WriteStartTag(type, field, xml);
            WriteAfterStartTag(value, field, xml, context, type);
        }
예제 #12
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)
		{
			MethodInfo info				= value as MethodInfo;
			ParameterInfo[] paramList	= info.GetParameters();

			if ( info.ReflectedType == null )
				throw new ConversionException( "Unable to serialize MethodInfo, no reflected type." );

            context.WriteStartTag( __type, field, xml );

			xml.WriteElementString( "base", context.GetTypeName( info.ReflectedType ) );
			xml.WriteElementString( "name", info.Name );
			
			xml.WriteStartElement( "params" );
			foreach ( ParameterInfo paramInfo in paramList )
				xml.WriteElementString( "param", context.GetTypeName( paramInfo.ParameterType ) );	
			xml.WriteEndElement();
			
			context.WriteEndTag( __type, field, xml );
		}
        /// <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)
        {
            context.WriteStartTag(__type, field, xml);

            string dateTimeWithColon = ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss.fff");

            xml.WriteString(dateTimeWithColon);

            //string dateTimeWithColon = ((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss.fffzzz");
            //System.Text.RegularExpressions.Regex
            //    regexTimeZone
            //        = new System.Text.RegularExpressions.Regex(@"\+(\d{2}):(\d{2})",
            //        System.Text.RegularExpressions.RegexOptions.Compiled |
            //        System.Text.RegularExpressions.RegexOptions.IgnoreCase);

            //string res = regexTimeZone.Replace(dateTimeWithColon, @"+$1$2");
            //xml.WriteString(res);

            context.WriteEndTag(__type, field, xml);
        }
예제 #14
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);
        }
예제 #15
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)
 {
     context.WriteStartTag(__type, field, xml);
     xml.WriteString((value as Type).AssemblyQualifiedName);
     context.WriteEndTag(__type, field, xml);
 }
예제 #16
0
 public virtual void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context)
 {
     context.WriteStartTag(type, field, xml);
     xml.WriteString(((ControlType)value).Id.ToString());
     context.WriteEndTag(type, field, xml);
 }
예제 #17
0
 public virtual void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context)
 {
     context.WriteStartTag(type, field, xml);
     xml.WriteString(((ControlType) value).Id.ToString());
     context.WriteEndTag(type, field, xml);
 }
 /// <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)
 {
     context.WriteStartTag(__type, field, xml);
     xml.WriteString(((DateTime)value).Ticks.ToString());
     context.WriteEndTag(__type, field, xml);
 }
예제 #19
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)
		{
			context.WriteStartTag( __type, field, xml );
			xml.WriteString( ( (TimeSpan) value ).Ticks.ToString() );
			context.WriteEndTag( __type, field, xml );
		}
예제 #20
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)
		{
			context.WriteStartTag( __type, field, xml );
			xml.WriteString( (value as Type).AssemblyQualifiedName );
			context.WriteEndTag( __type, field, xml );
		}
예제 #21
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)
 {
     context.WriteStartTag(__type, field, xml);
     xml.WriteCData(value.ToString());
     context.WriteEndTag(__type, field, xml);
 }