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