[Mono-list] Xml.Serialization empty element
David Waite
dwaite at gmail.com
Tue Apr 18 23:46:02 EDT 2006
In the past I've done this sort of bridge work using hacks like named
elements/attributes and ignored accessors. For example
[XmlIgnore]
public bool MyFlag;
[XmlElement("MyFlag")]
public EmptyObject _MyFlag
{
get { return MyFlag ? EmptyObject() : null; }
set { MyFlag = (value != null) }
}
-David Waite
On 4/18/06, Dominik Zablotny <doza at sztorm.net> wrote:
> Dnia 18-04-2006, wto o godzinie 12:05 -0500, Jonathan Gilbert
> napisał(a):
> > Just to elaborate on this (for the original poster), XML serializtion was
> > designed with the goal of generating XML for instances of existing data
> > types, and so using it for the inverse mapping -- taking an arbitrary XML
> > structure and mapping a hierarchy of C# data types onto it -- is something
> > that is not guaranteed to work.
>
> But it's sooo convenient :P
>
> > One approach to slightly sweeten the syntax might be to add an implicit
> > conversion from your dummy class to 'bool':
>
> That solves reading bool from program, but not writing it. Anyway, I can
> live with my current solution. Thanks for all answers.
>
> --
> Dominik Zablotny
> xmpp:doza at chrome.pl
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
More information about the Mono-list
mailing list