473,785 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 AllShoppingBask ets that will hold all
the ShoppingBaskets . The resulting XML I am after should look like
this.

<AllShoppingBas kets>
<ShoppingBasket >
<Item>
<ItemType>ItemT ype</ItemType>
<ItemCaption>It emCaption</ItemCaption>
</Item>
</ShoppingBasket >
</AllShoppingBask ets >

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 AllShopingBaske t 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 :
ConfigurationMa nager.WriteConf iguration("shop pingbasketsetti ngs",
configData);
So in the ConfigData Class I have an AllShopingBaske ts property to be
serialized this way I would get

<AllShoppingBas kets>
<AllBaskets>
<anyType xsi:type="Shopp ingBasket">
<Items>
<anyType xsi:type="Item" >
<ItemType>ItemT ype</ItemType>
<ItemCaption>It emCaption</ItemCaption>
</anyType>
</Items>
</anyType>
</AllBaskets>
</AllShoppingBask ets>

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

Nov 17 '05 #1
0 973

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

Similar topics

0
1116
by: Alexandros__ | last post by:
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.
0
2029
by: Magne Ryholt | last post by:
Have a class with a public property named "TheFirstPropertyOfArrayListType" of type ArrayList, property has attribute XmlElement to describe the contents of the ArrayList, the contents is a public class with attribute XmlSerializable. This "second level" class named "SecondClass" has an attribute of type XmlSerializable, a public property of type ArrayList, with attribute XmlElement to describe the contents of the ArrayList, the contents...
10
3246
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our complexity analyzer tool supposedly does not pick it up. Is it really more efficient? Personally I find this coding style extremely cryptic, misleading and error-prone. I believe that I have removed all traces of proprietary-ness from this coding...
4
1975
by: Christopher Ireland | last post by:
Hi -- I'm trying to find an example of a nested class implemented within the .NET Framework itself but without much success. I don't suppose that anybody knows of such an example off the top of their head, do they? Many thanks! -- Best Regards,
0
1356
by: Kurt Ng | last post by:
Need help quick!!! Am really stuck on this problem! I have a C dll, and it uses a nested struct. (see below) The struct has 2 layers of nested structs. The first field in the first struct is a char*. I used StructLayout.Sequential to port each of the structs to C#, and I used UnmanagedType.LPStr to marshal the char* to C# string, but the resulting struct data are stored wrong when passed into the dll's api call. The char* is...
4
3148
by: MSDousti | last post by:
Hi all, I read some Q&As in the Net, discussing Marshalization of nested structs in C# (or VB.NET). Some guys stated that .NET framework does not support this feature yet. Are they right? BTW, by nested structs I mean structures such as this:
0
5323
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is written in C#. I created a small .exe file to test that the library builds propertly from configuration and that it communicates properly. This work great in the System.Windows.Forms. However, when I use the library in a web enviroment things...
5
1371
by: Macca | last post by:
Hi, I have a number of queue structures. I want to have multiple instances of these, i.e Instance 1 Instance 2 Instance 3 ... ------------ ------------ ------------ queueA queueB queueC I was thinking of usind a structure or a class to store the queues and then
3
1570
by: garyusenet | last post by:
Hi, As I continue to explore C# , Visual Studio, and Programming in general I am becoming increasingly hooked. I see myself definately studying and learning c# with visual studio over the next year or two and am frequently finding pieces of code i'd like to save for later use. Is there a better way than just saving the code files in a folder with a description of what each does?
1
1785
by: =?Utf-8?B?RGljaw==?= | last post by:
My Windows Application stores its configuration values in app.config and these are typed and accessed via corresponding classes, something like this... <configSections> <section name="Watcher"/> </configSections> <Watcher> <ClockWatcherCollection> <add Name="Blah"/>
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.