So last night, I was able to figure out how to download a log of all my transactions throughout the day
Authenticating with cookies was a pain because the CookieCollection object gets confused with cross-subdomain cookies (ie. .secondlife.com instead of secondlife.com)
So anyways, tonight I got on the ball with XmlSerialization – this handy namespace has an XmlSerializer that can serialize/deserialize xml into objects
Without it, I would have to create an XmlDocument and loop through each element off of the root document
Then depending on each child element, i would have to assign the innerText to different properties on my objects
Let’s just say XmlSerialization takes a lot of work out of the equation
Problem!
SecondLife transaction elements do not share a common name. Each element name has the id appended to it! i.e. transation_1234567. This makes it painful. Why the ID is in there i have no idea as “id” is repeated as a child element of the transaction.
To get around this, I simply used a regular expression.
xml = Regex.Replace(xml, “”, “”);
So yea … that solved the problem there and I was finally able to get my deserialized object just fine
I took it a step further an used a generic collection rather then an array. collections were introduced in .Net 2.0 and they are a god send!
[XmlElement("transaction", typeof(SecondLifeTransaction))] public Collection Transactions
So with that all done, I’m setting happy
well … not quite
I have issues with microsoft. I love to catch every exception within my debugger. even when they are caught and handled. My beef is that microsoft decided to look for assemblies that don’t exist for user-defined serializers.
so the MS Core library decided to complian that assemblies didn’t exist … twice. ugh! Although this doesn’t raise an error to the end user, it raises an exception to me as the developer.
Come on mr. gates – can’t you actually communicate amongst your core library without raising exceptions? or at least prevent me from seeing your “core” exceptions since I don’t have access to that code anyways.
To get around the problem, i created an empty library called LogViewer.XmlSerializers and referenced it from my LogViewer project. that fixed the exception problem just fine
End of Line
This entry was posted by Second Life resident Dedric Mauriac from Higgins.