Servergeek
Mickey Williams' weblog


Powered by Blogger Pro™

Thursday, May 20, 2004

SpeC#


Coming up on May 31st is the .NET Technologies conference in Pilsen. Earlier in the year I was hoping to get over to attend the conference but the work schedule has since exploded to the point that I hardly have time to think about places I had intended to visit. The conference features keynotes from both Rustan Leino (from MS Research) and Bertrand Meyer, and there are a number of exciting talks, including Rustan's presentation of SpeC#, a version of C# that includes support for Design by Contract. I met Rustan the last time I was in Redmond - he may be part of the vast underground Eiffel conspiracy. Okay, maybe not so vast.

BTW, Rustan has a great page of math and logic-oriented puzzles, if you're into that sort of thing.

Several (1.0 and 1.1) Ways to Serialize a Thing With XML


Lately, it seems like I get asked once a day, "How do I XML serialize an object into a {string|stream|XmlTextReader|etc.}". So I came up with several different ways to serialize an arbitrary object, and I'm putting them up here so that I'll be able to find them later.

Arbitrary object to string

static string SerializeThingToXmlString(object thing)
{
 StringWriter stringWriter = new StringWriter();
 XmlSerializer serializer = new XmlSerializer(thing.GetType());
 serializer.Serialize(stringWriter, thing);
 return stringWriter.ToString();
}

Arbitrary object to XmlTextReader

static XmlTextReader SerializeThingToXmlTextReader(object thing)
{
 MemoryStream ms = new MemoryStream();
 XmlSerializer serializer = new XmlSerializer(thing.GetType());
 serializer.Serialize(ms, thing);
 ms.Seek(0, SeekOrigin.Begin);
 return new XmlTextReader(ms);
}

Arbitrary object to XmlDocument

static XmlDocument SerializeThingToXmlDocument(object thing)
{
 XmlTextReader reader = SerializeThingToXmlTextReader(thing);
 XmlDocument doc = new XmlDocument();
 doc.Load(reader);
 return doc;
}

Tuesday, May 18, 2004

Extracting Roman's Brain


I'm consulting with Roman Kiss on some plumbing and service layerwork for a company on the financial end of the real-estate business. One of the things that Roman's working on in his spare time is spelunking the Indigo stack. This week, I was looking at some of the work that Roman had done, and instead of trying to copy the different source and project files, I just stole leveraged copied his Longhorn VHD, and presto - it was like Roman's brain had been transplanted into my laptop. One of the great things about VPC is how it simplifies sharing snapshots of a machine - both for testing, and sharing of information.

WS-I Releases Basic Security Profile WD


WS-I has just released the basic security security profile working draft, and it's full of interesting sharp edges in the security/interop space. Go there now...


Home