Hi group

I read XML data which i sometime can't know their type. But i have to show
the property in a property grid.

for example i get the following xml :

<UnknownClass><Prop1>value1</Prop1><Prop2>value2</Prop2><Prop3>value3</Prop3
></UnknownClass>

I can't have the declaration of UnknownClass, so i can't cast it in a known
type at the deserialization time. So i can't create an instance of the
object and can't show its properties.
But i am quite sure it is possible to create some object using the XML
definition, and dynamically re-create a basic structure that match the
properties, in order to juste show it in the property grid. but how can i do
that or workaroud it ?

i have googled for that and can't find any sample to deserialize unknown
data.
Please help.

ROM

RE: Deserialize an unknown class to show it in a property grid. by NoSpamMgbworld

NoSpamMgbworld
Fri Jan 07 07:59:01 CST 2005

You have a couple of options:

1. Run the XML for the object(s) through an XSLT transformation to look like
a DataSet and bind it to the Grid as data.

2. Run through the XML to get the object name and basic properties and code
gen an object. Reflection.Emit will allow you to compile the code gened
object.

For additional ideas, you can look at mock objects (SourceForge.net has a
.NET mock objects open source project). While mock objects are not set to
fulfill the exact need you have, the concept of creating them is similar.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


"Romain TAILLANDIER" wrote:

> Hi group
>
> I read XML data which i sometime can't know their type. But i have to show
> the property in a property grid.
>
> for example i get the following xml :
>
> <UnknownClass><Prop1>value1</Prop1><Prop2>value2</Prop2><Prop3>value3</Prop3
> ></UnknownClass>
>
> I can't have the declaration of UnknownClass, so i can't cast it in a known
> type at the deserialization time. So i can't create an instance of the
> object and can't show its properties.
> But i am quite sure it is possible to create some object using the XML
> definition, and dynamically re-create a basic structure that match the
> properties, in order to juste show it in the property grid. but how can i do
> that or workaroud it ?
>
> i have googled for that and can't find any sample to deserialize unknown
> data.
> Please help.
>
> ROM
>
>
>

Re: Deserialize an unknown class to show it in a property grid. by Romain

Romain
Mon Jan 10 03:02:38 CST 2005

thank you coboy !!

The first solution isn't applyable.

But the second is exactly what i need !!
Thank you for your graet help.

ROM

"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> a
écrit dans le message de
news:24965A88-2BED-45FE-8E1F-B37581C6D63D@microsoft.com...
> You have a couple of options:
>
> 1. Run the XML for the object(s) through an XSLT transformation to look
like
> a DataSet and bind it to the Grid as data.
>
> 2. Run through the XML to get the object name and basic properties and
code
> gen an object. Reflection.Emit will allow you to compile the code gened
> object.
>
> For additional ideas, you can look at mock objects (SourceForge.net has a
> .NET mock objects open source project). While mock objects are not set to
> fulfill the exact need you have, the concept of creating them is similar.
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Romain TAILLANDIER" wrote:
>
> > Hi group
> >
> > I read XML data which i sometime can't know their type. But i have to
show
> > the property in a property grid.
> >
> > for example i get the following xml :
> >
> >
<UnknownClass><Prop1>value1</Prop1><Prop2>value2</Prop2><Prop3>value3</Prop3
> > ></UnknownClass>
> >
> > I can't have the declaration of UnknownClass, so i can't cast it in a
known
> > type at the deserialization time. So i can't create an instance of the
> > object and can't show its properties.
> > But i am quite sure it is possible to create some object using the XML
> > definition, and dynamically re-create a basic structure that match the
> > properties, in order to juste show it in the property grid. but how can
i do
> > that or workaroud it ?
> >
> > i have googled for that and can't find any sample to deserialize unknown
> > data.
> > Please help.
> >
> > ROM
> >
> >
> >