all groups > dotnet xml > april 2007 >
You're in the

dotnet xml

group:

at runtime, get possible choices for xs:choice class


at runtime, get possible choices for xs:choice class GovernmentMan
4/26/2007 8:04:04 AM
dotnet xml:
Hi,
I am using Reflection to build a GUI based on a class create with XSD, in VB
..NET 2.0. For most elements, I can easily determine the Type and then
provide the user some controls to select what data to use (they are creating
an XML document essentially on the fly). But the choice element has several
possible types and so it creates this itemField as object within the
xs:choice-generated class:

Private itemField As Object

'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("DetectionCommand",
GetType(DetectionCommandType)), _
System.Xml.Serialization.XmlElementAttribute("ExtendedCommand",
GetType(ExtendedCommandType)), _
System.Xml.Serialization.XmlElementAttribute("LocationCommand",
GetType(LocationCommandType)), _
System.Xml.Serialization.XmlElementAttribute("SimpleCommand",
GetType(SimpleCommandType)), _
System.Xml.Serialization.XmlElementAttribute("TimeCommand",
GetType(TimeCommandType))> _
Public Property Item() As Object
Get
Return Me.itemField
End Get
Set(ByVal value As Object)
Me.itemField = Value
End Set
End Property

Is there any way to get the information in the "remarks" section during
runtime, perhaps that auto-generated info is also hiding somewhere else?
Really, I just want be able to determine at runtime what possible Types could
this itemField object take on? I would just throw an enumerated list or some
other hack inside this class, but there are many classes like this and I've
Re: at runtime, get possible choices for xs:choice class Petar Atanasov
5/7/2007 5:49:08 PM
[quoted text, click to view]

Hi,
Unless with the explicit declaration of ItemChoiceType enum, I'm not
aware of another way to get it runtime.
You can see detailed sample at:
http://msdn.microsoft.com/msdnmag/issues/03/06/XMLFiles/

HTH,
Petar Atanasov
AddThis Social Bookmark Button