473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

deserialization of xml with unknown object type?

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
5 3727

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Meta-Meta | last post by:
Hi, I'm trying to deserialize a VC++ .NET class and am stumped by the following problem : In order to create the XmlSerializer you need to pass the type of the object being created. The doc...
0
by: Dan Noel | last post by:
I am implementing a DataStore/Settings object that stores objects in XML by serializing the objects in XML and then associating these objects with key names. At some later point, I want to...
6
by: Nick Z. | last post by:
I need my program to start as fast as possible. Will deserialization a few settings using binary deserialization affect that? Or should I keep these settings in XML, will that be any better? ...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
0
by: PeterW | last post by:
I have a class which uses three other classes, two of which are used in arrays. This class is only ever used for incoming messages. All classes inherit from ISerializable and impliment...
3
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary...
0
by: Jeff Johnson | last post by:
"Chris Dunaway" <dunawayc@gmail.comwrote in message news:a3583dda-06cf-46af-ac96-bc35e3db15f4@c60g2000hsf.googlegroups.com... Even if you drop the switch statement, you're going to have to edit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.