Archive for the 'C#' Category

XmlUtils - serialize/deserialize an object to/from Xml in VB.Net

Friday, June 27th, 2008

Here is an implementation using VB.Net of XmlUtils class from my old post. Yesterday, I wrote an implementation of XmlConverter using VB.Net. As I wrote the idea is to provide the code in VB.Net for people that use VB.Net as their favourite programming language. Both XmlConverter and XmlUtils do the same but the second one is [...]

Serialize/Deserialize a Font and Color to/from XML

Thursday, June 26th, 2008

Not so long ago I needed to store some of UI appearance values of my project into a custom XML file in order to allow the end-user to configure its UI appearance. As it is expected I had to store also fonts and colors. Both of them can not be directly serialized into XML. For serializing/deserializing colors [...]

String aggregation and adding separator between each string

Wednesday, June 25th, 2008

Today, I found a nice blog - the blog of Peter Petrov. It contains a lovely set of posts of Useful Methods.
In one of its posts there is a really good implementation of string aggregation. There Peter said
Probably we can speed up my implementation by removing the check and removing the separator from the start but [...]

XmlConverter - serialize/deserialize an object to/from Xml (continue)

Tuesday, June 24th, 2008

Few days ago I wrote about a static class named XmlConverter. It contains few generic methods which allow an object to be serialized to XML or deserialized from XML. Today, I rewrite it to a XML utility class with extension methods. The following snippet contains the new class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Xml;

namespace XmlConverter.Utilities
{
 public static class XmlUtils
 {
  public static [...]

XmlConverter - serialize/deserialize an object to/from Xml

Friday, June 20th, 2008

Some time ago, I needed to serialize and deserialize different types of objects to/from XML. Because of that I decided to create a class with template methods to do this. The name of the class is XmlConverter (see below).

public static class XmlConverter
{

public static string ToXml<T>(T value) where T : new()
[...]