471,356 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Configuration Library - Nested structs/ArrayLists

Hello everyone,

I am using the Configuration Application block to write an XML
configuration file for my application. Most of it is working fine but I
have a problem serialising some nested structs that have arraylist
fields. What I want to do is to have a ShoppingBasket that will hold
any number of Itemstructs and an AllShoppingBaskets that will hold all
the ShoppingBaskets. The resulting XML I am after should look like
this.

<AllShoppingBaskets>
<ShoppingBasket>
<Item>
<ItemType>ItemType</ItemType>
<ItemCaption>ItemCaption</ItemCaption>
</Item>
</ShoppingBasket >
</AllShoppingBaskets >

To do this I created
- an Item struct:
public struct Item
{
public Item(string itemType, string itemCaption)...
}

- a ShoppingBasket struct:
public struct ShoppingBasket
{
public ShoppingBasket (ArrayList items)...
}
the items Arraylist will hold all the items of the basket.

- and an AllShopingBasket struct.
public struct Stations
{
public Stations (ArrayList allBaskets)...
}
the allBaskets Arraylist will hold all the ShoppingBaskets where every
basket will hold Items.

to serialise the data I am using :
ConfigurationManager.WriteConfiguration("shoppingb asketsettings",
configData);
So in the ConfigData Class I have an AllShopingBaskets property to be
serialized this way I would get

<AllShoppingBaskets>
<AllBaskets>
<anyType xsi:type="ShoppingBasket">
<Items>
<anyType xsi:type="Item">
<ItemType>ItemType</ItemType>
<ItemCaption>ItemCaption</ItemCaption>
</anyType>
</Items>
</anyType>
</AllBaskets>
</AllShoppingBaskets>

But if I have to have an Item and a ShoppingBasket as properties in the
ConfigData class or else I get an XML exception. If I do have those two
I get the above XML but also XML representations of Items and
ShopingBaskets which I don't want. If I use [XMLIgnore] on them it
breaks again.

Any ideas on what I am doing wrong or suggestion on doing this in a
different way?

Cheers

Jul 21 '05 #1
0 1020

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Magne Ryholt | last post: by
10 posts views Thread by nimmi_srivastav | last post: by
4 posts views Thread by Christopher Ireland | last post: by
4 posts views Thread by MSDousti | last post: by
reply views Thread by Alexandros__ | last post: by
1 post views Thread by =?Utf-8?B?RGljaw==?= | last post: by

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.