473,473 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Serialization & Deserialization

Greetings,

Let's say I have a simple class:

namespace Com.Company.Group
{
[XmlRoot("factory")]
public class Factory
{
protected ArrayList widgets;

[
XmlArray("widgets"),
XmlArrayItem("widget", typeof(Widget))
]
public ArrayList Widgets
{
get { return this.widgets; }
set { this.widget= value; }
}
}
}

When an instance of Factory class gets serialized (using XmlSerializer)
the following XML is produced:

<?xml version="1.0" encoding="utf-8"?>
<factory xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<widgets>
<widget xsi:type="WidgetA">
</widget>
<widget xsi:type="WidgetB">
</widget>
</widgets>
</factory>

I see a problem here. xsi:type for <widget> doesn't include namespace.
I would expect something like:

<widget xsi:type="Com.Company.Group.WidgetA"/>

What if I have classes with the same name but from different
namespaces? I know that both XmlArray and XmlArrayItem accept
"Namespace" parameter but it's not an option here as subclasses for
Widget may come from different namespaces (and different DLL's). If I
specify Namespace for a certain widget class, it gets ignored by
XmlArray, for example:

[XmlRoot("widget", Namespace="urn:com.company.unit")]
public class WidgetX: Widget
{
}

Any way to have xsi:type containing a full type description like
"Com.Company.Group.WidgetA" instead of just "WidgetA"?

Thanks,
Yuriy

Nov 12 '05 #1
1 1129
I believe I found a solution. It's XmlType.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
4
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these...
0
by: Johann Blake | last post by:
I have an application that runs on a web server that sends data to clients over a TCP socket. The data comes from a class that has been serialized. The class exists in a library (a DLL). The...
1
by: Maheal | last post by:
I have been trying to Serialize an object that is the child of another object which is also serializable. Here is the simplified scenario (assume missing code is correct): class One :...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
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
0
by: Goethals Frederik | last post by:
Hi, I have some questions that are a little difficult to explain, so I give it a try... I have an application (aSP.NET with VB.NET codebehind) and I would like to store my data on disk...
1
by: Rucha | last post by:
We are using ACAServices in our project, and are passing entity classes as parameters to the ACAServiceMethod. We are using a private variable entityState to indicate whether the entity is...
5
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the...
3
by: Zachary Turner | last post by:
Hello, I have a situation where I would like to perform custom serialization and deserialization of an existing .NET framework object (specifically, System.DateTime). Is there a common paradigm...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.