I had a problem getting TypeConverters to work with generic lists in XNA and WinForms. The designer wouldn't generate the code I wanted for properties. I needed a simple way to serialize objects, so I tried a minimalist approach. Overriding CanConvertTo and ConvertTo methods in my TypeConverter was enough for the designer to serialize the objects correctly, generating much cleaner and simpler code.
In this post, I describe a solution to a problem I encountered while working with XNA Beta1 and Vector2 structs. Because Vector2 didn't have an associated TypeConverter, the designer lacked support. Applying a TypeConverter to the property worked in the designer, but Visual Studio 2005 ignored it during serialization, resorting to resource files, which was messy. My workaround involves dynamically adding a TypeConverter to the Vector2 type itself using TypeDescriptor.AddAttributes, which is invoked during the class's construction. By registering the Vector2Converter with the Vector2 type early on, both the designer and code serialization work harmoniously.
I've just posted the C# source code for serializing and deserializing OPML files using a simple object model. The code demonstrates basic serialization and deserialization, creating an OPML structure with a head, body, and outline elements. While the object model is functional, it's not perfect and could be refined. The example code shows how to create an OPML object, populate it with sample data, serialize it to XML, and then deserialize it back into an object, useful for anyone working with OPML in C#.
I'm working on a .NET object model for OPML 2.0 to easily serialize and deserialize OPML files. Serialization is working well and creates correctly formatted files thanks to constraints based on the OPML spec. Deserialization is proving tricky as the XML Deserializer isn't enforcing those same constraints, allowing incorrectly structured OPML files to be loaded. I'll share the code and continue working on it.
I've posted another update to my ICMP ping tutorial series on MSDN Blogs. This installment focuses on crucial aspects like calculating checksums and serializing packets into byte arrays for transmission. While we haven't started sending data over the wire, understanding these concepts is vital for the next steps. Check out the post for more detail.
In this first part of my image processing series, I'm sharing how I used the Yahoo Search API to find images and load them into a C# application. I was excited to discover how straightforward it is to query for images and then seamlessly integrate the results into my project. The process involves constructing a REST query with search parameters, sending the request to Yahoo, receiving the XML response, and deserializing it into a custom data type. Then, I iterate through each image result in the response, create another query to download the image, and finally, convert the downloaded stream into a Bitmap and load it into an ImageList. Stay tuned for more in this series!