Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Force XmlSerializer to access properties differently?

From: "JordanB" <none@----.--->
To: NULL
Date: 4/28/2009 1:23:00 PM
I have a custom object which I'm serializing.  There's a string property 
which contains non-xml-safe HTML text.  When I try to deserialize, I get a 
reflection exception if it hits the property.

        Dim xmlFact As New Xml.Serialization.XmlSerializerFactory
        Dim LeftXML As Xml.Serialization.XmlSerializer = 
xmlFact.CreateSerializer(Me.GetType)
        Dim myxml As System.IO.TextReader = New IO.StringReader(XML)
        Dim returnProductListItem As ProductListItem = 
CType(LeftXML.Deserialize(myxml), ProductListItem)


What I'd like is if during the serialization process, the property was 
somehow called from within a wrapper...

I fumbled around a bit, hoping this would work:

    '\\ Use HTMLExtendedSpecs property for day-to-day use:
    '\\ ignore for XML, because we're using HTMLComments_Deserialization 
instead
    <Xml.Serialization.XmlIgnore()> _
    Public Property HTMLExtendedSpecs() As String
        Get
            Return m_strHTMLExtendedSpecs
        End Get
        Set(ByVal Value As String)
            m_strHTMLExtendedSpecs = Value
        End Set
    End Property


    '\\ when the serializer tries to read this property, serialize it as 
HTMLExtendedSpecs
    <Xml.Serialization.XmlElement("HTMLExtendedSpecs")> _
    Public ReadOnly Property HTMLExtendedSpecs_Deserialization() As String
        Get
            Return MakeXMLSafe(Me.HTMLExtendedSpecs)
        End Get
    End Property



This didn't work.  What I was hoping for was to provide the serialization 
classes to access the property differently.

Any suggestions?



Jordan. 



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent