Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:53:09+00:00 2026-05-31T15:53:09+00:00

I have a custom configuration setup. public class GalleryResizeOptionsElement : ConfigurationElement { [ConfigurationProperty(name)] public

  • 0

I have a custom configuration setup.

public class GalleryResizeOptionsElement : ConfigurationElement
{
    [ConfigurationProperty("name")]
    public string Name
    {
        get { return (string)this["name"]; }
    }

    [ConfigurationProperty("width")]
    public int Width
    {
        get { return (int)this["width"]; }
    }

    [ConfigurationProperty("height")]
    public int Height
    {
        get { return (int)this["height"]; }
    }
}

public class GalleryResizeOptionsCollection : ConfigurationElementCollection
{
    protected override ConfigurationElement CreateNewElement()
    {
        return new GalleryResizeOptionsElement();
    }

    protected override object GetElementKey(ConfigurationElement element)
    {
        return ((GalleryResizeOptionsElement)element).Name;
    }


    public override ConfigurationElementCollectionType CollectionType
    {
        get { return ConfigurationElementCollectionType.BasicMap; }
    }

    /// <summary>
    /// The element name of the configuration elements in the config file,
    /// as set at UserCommandConfigurationConstants.ElementName
    /// </summary>
    protected override string ElementName
    {
        get { return "add"; }
    }

    /// <summary>
    /// This is a convenience added to allow selection from the collection
    /// via the commandkey as an index
    /// </summary>
    /// <returns></returns>
    public GalleryResizeOptionsElement this[string name]
    {
        get { return (GalleryResizeOptionsElement)this.BaseGet(name); }
    }
}

public class GalleryConfigurationSection : ConfigurationSection
{

    public virtual GalleryResizeOptionsCollection ResizeOptions
    {
        get { return (GalleryResizeOptionsCollection) base["resizeOptions"]; }
    }
}

Add in the web.config file there is a section that contains this xml config.

<resizeOptions>
        <add name="Square" width="100" height="100" />
        <add name="Rectangle" width="200" height="100" />
        <add name="Hero" width="600" height="400" />
      </resizeOptions>

I’ve left a lot of the other code out for brevity, but I think I’ve included everything that is required to ask my question.

How do I alter GalleryResizeOptionsCollection so that I can return a list of all the GalleryResizeOptionsElements? Or in clearer terms, I want to be able to return a list of all the “add” elements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:53:11+00:00Added an answer on May 31, 2026 at 3:53 pm

    You can use System.Linq to return a list of elements:

    using System.Linq;
    
    public class GalleryResizeOptionsCollection : ConfigurationElementCollection
    {
       //...
    
       public IList<GalleryResizeOptionsElement> ToList()
       {
          return this.Cast<GalleryResizeOptionsElement>().ToList();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Setup Project which uses a System.Configuration.Install.Installer Class forhandling some custom actions.
I have a custom initializer setup as follows: public class PromptIfChangesNeededDBInitializer : IDatabaseInitializer<MeyerREContext> {
I have a setup project with a custom installer class which launch the application
I have a windows service that has a custom configuration section. In the configSectionHandler
I need to setup a custom action within WiX 3.0. I have the following
I have a custom configuration section registered in the app/web.config, let's call it MySection
I have a custom project type based on the C# Class Library project type
I have created a custom Rewrite Provider for IIS 7 following instructions in this
I have a C# project targeted for x64 platforms. This project includes a System.Configuration.Install.Installer
For an integration test setup, we have written some custom scripts and code to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.