ASP Forum
Informant: Another serialization question
Kodo | Posted 9:51am 3. November 2005 Server Time |

How in the hell would I build an object that could serialize to this:

<?xml version="1.0" encoding="UTF-8" ?>
<XMLPayRequest Timeout="30" version="2.0" xmlns="http://www.verisign.com/XMLPay">
<RequestData>
<Vendor>vendor</Vendor>
<Partner>VeriSign</Partner>
<Transactions>
<Transaction>
<Authorization>
<PayData>
<Invoice>
<BillTo>
<Address>
<Street>123 4th street</Street>
<City>San Jose</City>
<State>CA</State>
<Zip>95032</Zip>
<Country>USA</Country>
</Address>
</BillTo>
<TotalAmt>24.97</TotalAmt>
</Invoice>
<Tender>
<Card>
<CardType>visa</CardType>
<CardNum>5105105105105100</CardNum>
<ExpDate>200911</ExpDate>
<NameOnCard />
</Card>
</Tender>
</PayData>
</Authorization>
</Transaction>
</Transactions>
</RequestData>
<RequestAuth>
<UserPass>
<User>user</User>
<Password>password</Password>
</UserPass>
</RequestAuth>
</XMLPayRequest>
Kodo | Posted 1:47pm 3. November 2005 Server Time |

All the articles I see use Collection base because it already uses Ilist. What's the drawback compared to what you were telling me with regards to not inheriting Collectionbase in my class?
Informant | Posted 2:10pm 3. November 2005 Server Time |

dude your container class should not be a strongly typed class your are breaking OO principales of encapsulation and coupling you need to create a seperate class called transactions this class is your strongly typed collection and will inherit from collection base. This class will have types of Transaction which is the class you already created. Do you understand strongly typed now? You know the type and there can only be one type and its a collection of that type which equals a strongly typed collection.
Kodo | Posted 6:23am 4. November 2005 Server Time |

think I have it.. does this look correct?
Imports System.Xml
Imports System.IO
Imports System.Xml.Serialization

<Serializable(), XmlRoot(ElementName:="XMLPayRequest", NameSpace:="http://www.verisign.com/XMLPay")> _
Public Class XMLPayRequest



    <Serializable()> _
    Public Class RequestData


        Private _vendor As String
        Private _partner As String


        Public Property Vendor() As String
            Get
                Return _vendor
            End Get
            Set(ByVal Value As String)
                _vendor = Value
            End Set
        End Property

        Public Property Partner() As String
            Get
                Return _partner
            End Get
            Set(ByVal Value As String)
                _partner = Value
            End Set
        End Property

        Sub New()

        End Sub

    End Class


    Sub New()

    End Sub

End Class
Kodo | Posted 6:26am 4. November 2005 Server Time |

crap..can't post the whole thing.. I'll email it to you..
Kodo | Posted 10:16am 4. November 2005 Server Time |

I'm not understanding this. If I create these nested classes then:
1. How does it serialize the containing class?
2. How do I instantiate the object?

If I instantiate the class that contains the properties, then only that class is serialized. None of the container classes are serialized.. :/ help?


Reply to Post Informant: Another serialization question



Back to Forum Page