473,320 Members | 1,831 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,320 software developers and data experts.

customer configuration

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"/>
</ClockWatcherCollection>
</Watcher>

Friend Class Watcher

Inherits System.Configuration.ConfigurationSection

<System.Configuration.ConfigurationProperty("Clock WatcherCollection",
IsRequired:=True)_
Friend ReadOnly Property ClockWatcherCollection() As
ClockWatchCollection
Get
Return Me("ClockWatcherCollection")
End Get
End Property

End Class

Friend Class ClockWatchCollection

Inherits System.Configuration.ConfigurationElementCollectio n

Protected Overloads Overrides Function CreateNewElement() As
System.Configuration.ConfigurationElement
Return New ClockWatch
End Function

Protected Overrides Function GetElementKey(ByVal Element As
System.Configuration.ConfigurationElement) As Object
Return CType(Element, ClockWatch).Name
End Function

Friend Shadows Function Item(ByVal Name As String) As ClockWatch
Return MyBase.BaseGet(Name)
End Function

End Class

Friend Class ClockWatch

Inherits System.Configuration.ConfigurationSection

<System.Configuration.ConfigurationProperty("Name" , IsRequired:=True)_
Friend ReadOnly Property Name() As String
Get
Return Me("Name")
End Get
End Property

End Class

This works fine for simple types, such as the Name property above, but I
can’t see how to do the same for complex types like the collection of
Notification types and the LogFile type below…

<Watcher>
<ClockWatcherCollection>
<add Name="Blah">
<Notification Address="Blah"/>
<Notification Address="Blah"/>
<Notification Address="Blah"/>
<LogFile Name="Blah", MaxSize="Blah", Delete="Blah"/>
</add>
</ClockWatcherCollection>
</Watcher>
May 18 '07 #1
1 1757
Hi Dick,

From your description, you're wantting to add some custom configuration
section to the applicaiton config file, and some of the configure element
contains item collections, and you met some problem to get complex type
collection in the custom configsection, correct?

Based on my understanding, the .net framework 2.0 custom configuration
interface support two kinds of custom configuration handler:

1. derive your custom configuration section class from
"ConfigurationSection" class, and any sub property/section from
"ConfigurationElement" or "ConfigurationElementCollection". And if you
want to add custom item collection this way, you can only contains a single
type of element in one colleciton and use "<add>", "<remove>" element to
add or remove item. e.g.

==================
<urls>
<clear />
<add
name="Microsoft" url="http://www.microsoft.com" port="0"
lockAllAttributesExcept="port" />
<add
name="Contoso" url="http://www.contoso.com/" port="8080"
lockAllAttributesExcept="port" lockItem="true" />
</urls>
========================

and it only support simple/basic types rather than nested complex
properties.
2. For your scenario, if you want to add complex nested properties for each
item in configuration colleciton/list, I'm afraid you may need to write a
custom section handler and use raw XML API or XML serialization api to
manage the XML content of the section directly. see the following MSDN
reference:

#How to: Create Custom Configuration Sections Using
IConfigurationSectionHandler
http://msdn2.microsoft.com/en-us/library/ms228056.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.



May 21 '07 #2

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

Similar topics

8
by: aa | last post by:
If I have a customers database and wanted to automastically create and post an email from a local computer to each customer of the same content - can I do it in PHP? If affirmative which...
12
by: jason | last post by:
Access 2000: I have a customer-inventory table I need to loop through and compile a list of all the inventory items the customer is tracking. The problem I am finding is that a simple loop...
1
by: The Blob | last post by:
Hi all, I have a problem trying to generate the u/m list of customer. I am trying to generate a list of customer whoes last commence date is jan 04 to current. It is part of a billing...
4
by: sara | last post by:
I am learning with a simple application/form. I am ok - enter customer name, list box of customers, select a customer, see the items for that customer. The items form has customer ID and Name...
4
by: hazz | last post by:
The data access layer below returns, well, a mess as you can see on the last line of this posting. What is the best way to return customer objects via a datareader from the data layer into my view...
1
by: Herman Beeksma | last post by:
Hi there! I have two tables: Customer (ID, Name) Invoice (ID, Date, Customer, Amount) and want to select only the *last* invoice for each customer. It's easy to get each customer's last...
5
by: Stefano Peduzzi | last post by:
Hi, I'm building an application where I've defined a custom class Customer. Customer can have many phones (defined by phoneType and phoneNumber). I want to check that a phoneNumber is not already...
3
by: dancole42 | last post by:
I'm self-taught in Access, and as such I'm missing large chunks of knowledge, so I'm hoping someone here with some training can help me. Right now I have an Invoice form with a Customer subform....
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.