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

enumerator in custom configuration section

greetings!
In my asp.net application, I created a custom section in web.config that contain strings that are quotes to display in my home page. Every request for my home page (default.aspx) grabs a quote based on a random index.

my web.config section looks like this:
<configSections>
...
<section name="quotesSection" type="QuotesSection"/>
</configSections>

<quotesSection>
<quotesCollection>
<add value=" quote text here"/>
.......
</quotesCollection>
</quotesSection>

in my quotesHandler class I have the following:

public class QuotesCollection : ConfigurationElementCollection, IEnumerable
{
.....
#region IEnumerable Members

IEnumerator IEnumerable.GetEnumerator()
{
return (IEnumerator)new QuotesEnumerator(this);
}

#endregion
}

The region above was created by visual studio (when I clicked the option to "Explicitly Implement interface 'IEnumerable' " after hovering over the IEnumerable keyword).

I have a static class "myQuotes" that populates a List<string> object like so:

public static class myQuotes
{
static public List<string> quotes = new List<string>();

staticmyQuotes()
{

QuotesSection _quotes = (QuotesSection)ConfigurationManager.GetSection("qu otesSection");
foreach (Quote quote in _quotes.quotes)
{
quotes.Add(quote.Value);
}

}

This is a learning experiment in implementing interfaces, specifically IEnumerable and IEnumerator.
So this works fine, but when I set a break point at the GetEnumerator() method in the QuotesCollection class (which implements IEnumerable), it never stops there, the foreach loop just works. I am not implementing any of the IEnumerator methods (Current(), Reset(), MoveNext()...).

I was able to code my own GetEnumerator() method and return my own IEnumerator class which implemented the required methods.
Is that overriding the base class (ConfigurationElementCollection) implementation of IEnumerator? Meaning - the GetEnumerator method is never called from my code?


Thanks in advance.
Nov 26 '09 #1
0 1818

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Søren Lund | last post by:
Hello, I have implemented a custom config section handler by implementing the IConfigurationSectionHandler interface. I have registered this handler in web.config and everything works fine ......
4
by: Nick Gilbert | last post by:
Hi, I would like the ability to store the configuration settings for all versions of my site in a single web.config file by using different sections. Eg: <siteConfig> <machine name="XENON">...
3
by: rdcpro | last post by:
Hi all, I've been building a nifty deserializing configuration handler that I use in conjunction with my web.config in an ASP.NET web app. This is working quite well, but I'm planning on...
6
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
6
by: Jeff Hegedus | last post by:
I have a dll that requires some configuration data. I put the configuration data in a custom configuration section in a config file that is loaded in the installation folder of the dll. If I...
7
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
0
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I have a web.config custom configuration section using asp.net 2.0 configuration APIs. My custom configuration section inherits from System.Configuration.ConfigurationSection. I have a IIS root...
1
by: =?Utf-8?B?SmFzb24gUmljaG1laWVy?= | last post by:
This may have been addressed in another post but I was unable to find what I was looking for. I am trying to create a custom configuration section that is element-centric instead of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.