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

deserialization of xml with unknown object type?

P: n/a
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class. Is
there a way to create an object from the xml code itself without casting it
through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken
Jan 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"KenK" <te******@helpconsulting.net> wrote in message
news:26***************************@ALLTEL.NET...
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class. Is
there a way to create an object from the xml code itself without casting it through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken


If you want to serialize data using XML then you have to have the requisite
information about the 'types' represented in XML.
Visual Studio can/does this for you. The 'types' I refer to will be likely a
reflection of an underlying datalayer that provides relational information
to the calling class about the tables in that data layer. Table names and
table column names lend themselves well to XML structured documents.

Not sure what you mean about 'allow the end user to create their own object
classes?'

LW
Jan 10 '06 #2

P: n/a
Ken,

You can use true serialization (using an implementation of IFormatter)
and you can have fields of type object which are serialized/deserialized
correctly. However, with XML serialization, you need to know the types of
the objects being exposed, because of the way that it works (using public
properties on the exposed type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"KenK" <te******@helpconsulting.net> wrote in message
news:26***************************@ALLTEL.NET...
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class. Is
there a way to create an object from the xml code itself without casting
it through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken

Jan 10 '06 #3

P: n/a
thanks,

The idea is that the end user opens an xml file and the content of that xml
file would be displayed in a propertygrid with the xml field names
representing names in the propertygrid and the values would be in the right
(values) column.

Thanks again,
Ken

"Robert Johnson" <ro*********@yahoo.com> wrote in message
news:TCDwf.57267$Ou3.29367@dukeread09...

"KenK" <te******@helpconsulting.net> wrote in message
news:26***************************@ALLTEL.NET...
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class.
Is
there a way to create an object from the xml code itself without casting

it
through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken


If you want to serialize data using XML then you have to have the
requisite
information about the 'types' represented in XML.
Visual Studio can/does this for you. The 'types' I refer to will be likely
a
reflection of an underlying datalayer that provides relational information
to the calling class about the tables in that data layer. Table names and
table column names lend themselves well to XML structured documents.

Not sure what you mean about 'allow the end user to create their own
object
classes?'

LW

Jan 10 '06 #4

P: n/a
Ken,

In this case, you don't necessarily need to use serialization for this.

You can create a class that implements ICustomTypeDescriptor and exposes
the properties to show in the property grid.

You just have your class load the XML file, and then have the
GetProperties method return the properties that correspond to the data in
the file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"KenK" <te******@helpconsulting.net> wrote in message
news:61***************************@ALLTEL.NET...
thanks,

The idea is that the end user opens an xml file and the content of that
xml file would be displayed in a propertygrid with the xml field names
representing names in the propertygrid and the values would be in the
right (values) column.

Thanks again,
Ken

"Robert Johnson" <ro*********@yahoo.com> wrote in message
news:TCDwf.57267$Ou3.29367@dukeread09...

"KenK" <te******@helpconsulting.net> wrote in message
news:26***************************@ALLTEL.NET...
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class.
Is
there a way to create an object from the xml code itself without casting

it
through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken


If you want to serialize data using XML then you have to have the
requisite
information about the 'types' represented in XML.
Visual Studio can/does this for you. The 'types' I refer to will be
likely a
reflection of an underlying datalayer that provides relational
information
to the calling class about the tables in that data layer. Table names and
table column names lend themselves well to XML structured documents.

Not sure what you mean about 'allow the end user to create their own
object
classes?'

LW


Jan 10 '06 #5

P: n/a
thank you much. I will investigate this.

ken

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP12.phx.gbl...
Ken,

In this case, you don't necessarily need to use serialization for this.

You can create a class that implements ICustomTypeDescriptor and
exposes the properties to show in the property grid.

You just have your class load the XML file, and then have the
GetProperties method return the properties that correspond to the data in
the file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"KenK" <te******@helpconsulting.net> wrote in message
news:61***************************@ALLTEL.NET...
thanks,

The idea is that the end user opens an xml file and the content of that
xml file would be displayed in a propertygrid with the xml field names
representing names in the propertygrid and the values would be in the
right (values) column.

Thanks again,
Ken

"Robert Johnson" <ro*********@yahoo.com> wrote in message
news:TCDwf.57267$Ou3.29367@dukeread09...

"KenK" <te******@helpconsulting.net> wrote in message
news:26***************************@ALLTEL.NET...
Hi all,

Been reading all day about object serialization techniques in C# and my
problem is that everything I read is requiring a "known" object class.
Is
there a way to create an object from the xml code itself without
casting
it
through an object?

If not, what is the best way to allow the end user to create their own
object classes?

Thanks,
Ken

If you want to serialize data using XML then you have to have the
requisite
information about the 'types' represented in XML.
Visual Studio can/does this for you. The 'types' I refer to will be
likely a
reflection of an underlying datalayer that provides relational
information
to the calling class about the tables in that data layer. Table names
and
table column names lend themselves well to XML structured documents.

Not sure what you mean about 'allow the end user to create their own
object
classes?'

LW



Jan 10 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.