Why the collection property is not included in the ouput
serialization ?
I have a custom generic collection (implements icollection): Events of
objects: Event.
Event is a simple class exposing, let's say, one property: name
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
Events Implements ICollection
Public EventColor as string
........
Everything works except when I save the xml file I'm expecting to get
smth like:
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
EVENTCOLOR attribute is not in the xml, any idea ?
Thanks,
xke 4 1445
In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?
--
Andrew Faust
andrew[at]andrewfaust.com http://www.andrewfaust.com
"xke" <xk****@gmail.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.com...
Why the collection property is not included in the ouput
serialization ?
I have a custom generic collection (implements icollection): Events of
objects: Event.
Event is a simple class exposing, let's say, one property: name
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
Events Implements ICollection
Public EventColor as string
........
Everything works except when I save the xml file I'm expecting to get
smth like:
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
EVENTCOLOR attribute is not in the xml, any idea ?
Thanks,
xke
Hi Andrew,
Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.
It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.
Thanks,
xke
On Oct 22, 10:06 pm, "Andrew Faust" <and...@andrewfaust.comwrote:
In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?
--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com
"xke" <xke...@gmail.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.com...
Why the collection property is not included in the ouput
serialization ?
I have a custom generic collection (implements icollection): Events of
objects: Event.
Event is a simple class exposing, let's say, one property: name
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
Events Implements ICollection
Public EventColor as string
........
Everything works except when I save the xml file I'm expecting to get
smth like:
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
EVENTCOLOR attribute is not in the xml, any idea ?
Thanks,
xke- Hide quoted text -
- Show quoted text -
Sorry. Misread your original post.
According to this article the Serializer only supports writing out the
actual objects contained in an ICollection and not the actual properties of
the collection itself. http://www.diranieh.com/NETSerializa...ialization.htm
I would recommend a slight restructuring to something like this
class Events
{
public string EventColor;
private List<Eventm_Events;
public Event[] UpcomingEvents
{
get { return m_Events.ToArray(); }
set {
m_Events = new List<Event>();
m_Events.AddRange(value);
}
}
}
Then serialize the Events class.
"xke" wrote:
Hi Andrew,
Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.
It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.
Thanks,
xke
On Oct 22, 10:06 pm, "Andrew Faust" <and...@andrewfaust.comwrote:
In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?
--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com
"xke" <xke...@gmail.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.com...
Why the collection property is not included in the ouput
serialization ?
I have a custom generic collection (implements icollection): Events of
objects: Event.
Event is a simple class exposing, let's say, one property: name
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
Events Implements ICollection
Public EventColor as string
........
Everything works except when I save the xml file I'm expecting to get
smth like:
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
EVENTCOLOR attribute is not in the xml, any idea ?
Thanks,
xke- Hide quoted text -
- Show quoted text -
beautiful idea / will give it a try tomorrow
thanks,
xke
On Oct 23, 1:28 pm, Andrew Faust <afa...@nospam.nospamwrote:
Sorry. Misread your original post.
According to this article the Serializer only supports writing out the
actual objects contained in an ICollection and not the actual properties of
the collection itself.
http://www.diranieh.com/NETSerializa...ialization.htm
I would recommend a slight restructuring to something like this
class Events
{
public string EventColor;
private List<Eventm_Events;
public Event[] UpcomingEvents
{
get { return m_Events.ToArray(); }
set {
m_Events = new List<Event>();
m_Events.AddRange(value);
}
}
}
Then serialize the Events class.
"xke" wrote:
Hi Andrew,
Yes, EventName gets serialized as member of Event class. Question
would be: why the parent collection class properties don't get
serialized ?
Problem I have is not with the Event class but with Events class (the
collection). I thought Events class members will be also serialized.
It's quite basic what I am trying to do, it should work. If you have
any ideas pls help.
Thanks,
xke
On Oct 22, 10:06 pm, "Andrew Faust" <and...@andrewfaust.comwrote:
In your example EventColor isn't a part of the class Event, and thus
wouldn't get serialized along with it. The only member Event has is
EventName. Is EventName getting serialized? What output are you getting?
--
Andrew Faust
andrew[at]andrewfaust.comhttp://www.andrewfaust.com
"xke" <xke...@gmail.comwrote in message
>news:11**********************@e34g2000pro.googleg roups.com...
Why the collection property is not included in the ouput
serialization ?
I have a custom generic collection (implements icollection): Events of
objects: Event.
Event is a simple class exposing, let's say, one property: name
Public Class Event
<XmlAttribute("name")_
Public EventName As string
end class
Events Implements ICollection
Public EventColor as string
........
Everything works except when I save the xml file I'm expecting to get
smth like:
<?xml version="1.0" encoding="utf-8"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" EVENTCOLOR="some color">
<event eventname="some name" />
</events>
EVENTCOLOR attribute is not in the xml, any idea ?
Thanks,
xke- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jamie_m_ |
last post by:
I have a custom collection ... clFile that INHERITS from NameObjectCollectionBase the problem is, when I try to create an xmlserializer instance i get an error
You must implement a default...
|
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...
|
by: womber |
last post by:
I am getting XML from a dataset that has been populated via a storedprocedure
no schemas have been applied nor any relationships. But the correct table
names have been given to match the table(s)...
|
by: Just D. |
last post by:
All,
1. Did anybody write Serialization/Deserialization of some custom class
derived
from the CollectionBase class? The custom class is like a container of many
different simple classes, each...
|
by: George Ter-Saakov |
last post by:
I have 2 classes one is document and another is collection of documents.
When i am trying to use XmlSerializer to serialize class which has
clsDcoumentIds member variable i am getting an exception...
|
by: Tom |
last post by:
I am having a really annoying issue with serialization and a .NET User
Control I am writing. For example, let's say I have a couple of classes in
my control - first class is like:
Public Class...
|
by: Alex Clark |
last post by:
Hi all,
Apologies for the cross-post but I can't determine if this is a VS .NET
problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA,
VB.NET.
I'm coding a custom component...
|
by: crazyone |
last post by:
I've got a gaming framework i'm building and i want to save myself the
trouble of reading and writting the complete game data to a custom file
and load/save it to an XML file but i'm getting...
|
by: jsmith72 |
last post by:
Can some Please tell me why the following collection is not XML
Serializable:
Imports System.Xml
Imports System.Runtime.Serialization
Namespace MyNamespace
<Serializable()Public Class...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |