> I'm thinking of adding a more fluent interface to a set C# class in my
> current domain, the only thing that is causing me a dilemma is the fact that
[quoted text clipped - 3 lines]
> Does anyone have any experience with supporting a a fluent interface style
> on .Net classes that support xml serialisation?
The way I see it, the issue isn't supporting a fluent interface - it's
having mutable types. The two can coexist.
I'm afraid I don't know very much about XML Serialization, but I'd be
surprised if there weren't some way of intercepting the deserialization
in the class itself.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Ollie - 04 Mar 2008 17:00 GMT
hello Jon,
I'm sure (in fact I know) you can control the xml serialisation at a more
fine grained level but I'm trying not to go down that road at the moment...
Cheers
Ollie
> > I'm thinking of adding a more fluent interface to a set C# class in my
> > current domain, the only thing that is causing me a dilemma is the fact that
[quoted text clipped - 10 lines]
> surprised if there weren't some way of intercepting the deserialization
> in the class itself.
Marc Gravell - 04 Mar 2008 20:51 GMT
If you want to go with a fluent approach rather than getter/setter,
you'd need to handle IXmlSerializable yourself; note that you'd also
lose automatic schema visibility, and the ability to do standard data-
binding. And probably a few other ComponentModel things that I'm
forgetting. This sounds unncessarily painful.
Can I ask what the driver is for fluent in this case? If the problem
is primarily at instantiation, then perhaps consider C# 3 object
initializers? i.e.
Foo foo = new Foo {Width = 100, Length = 20, Name = "Fred", Foo =
"Bar", When = DateTime.Now };
Marc