473,243 Members | 1,546 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,243 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 3718

"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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.