By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,613 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,613 IT Pros & Developers. It's quick & easy.

at runtime, get possible choices for xs:choice class

P: n/a
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("Det ectionCommand",
GetType(DetectionCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Exte ndedCommand",
GetType(ExtendedCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Loca tionCommand",
GetType(LocationCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Simp leCommand",
GetType(SimpleCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Time Command",
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
gotten away with a very re-useable solution so far.
Apr 26 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
GovernmentMan wrote:
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("Det ectionCommand",
GetType(DetectionCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Exte ndedCommand",
GetType(ExtendedCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Loca tionCommand",
GetType(LocationCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Simp leCommand",
GetType(SimpleCommandType)), _
System.Xml.Serialization.XmlElementAttribute("Time Command",
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
gotten away with a very re-useable solution so far.
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/is...3/06/XMLFiles/

HTH,
Petar Atanasov
http://a-wake.net
May 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.