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 8512377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:15:50+00:00 2026-06-11T04:15:50+00:00

I’ve got a ConfigurationSection in my app.config which includes a list of http Endpoints

  • 0

I’ve got a ConfigurationSection in my app.config which includes a list of http Endpoints (~50). Each one has an optional priority (as well as a default).

I’d like to display this list in order.

Dim Config As MyConfigSection = DirectCast(System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None).Sections("MySection"), MyConfigSection)
Dim Endpoints = MyConfigSection.InitialEndpoints

In this case InitialEndpoints is of type Endpointcollection which Inherits ConfigurationElementCollection and is just a noddy collection which is loosely typed.

The Endpoint collection happens to deal with EndpointDefinitions which in turn have a Url, Priority, etc…

I’d like to be able to do…

For Each E in Endpoints.OrderBy(function(x) x.Priority)
    ...
Next

Do I really need to create a new list/collection and transfer the objects across, casting them as I go?

Cheating and casting the collection as an IEnumerable resulted in an invalid cast (not entirely unexpected)

An alternate thought was to do something like…

Endpoints.Select(function(x) DirectCast(x, Endpointdefinition)).OrderBy(...)

But EndpointCollection isn’t a list so doesn’t benefit from the LINQ Select() extension. I could always implement IList but now it feels like I’m using a sledgehammer to crack a nut.

Can someone please point out the obvious way to do this? For reference, my EndpointCollection is below

<ConfigurationCollection(GetType(EndpointDefinition), AddItemName:="Endpoint")>
    Public Class EndpointCollection
        Inherits ConfigurationElementCollection

        Protected Overloads Overrides Function CreateNewElement() As ConfigurationElement
            Return New EndpointDefinition
        End Function

        Protected Overrides Function CreateNewElement(elementName As String) As ConfigurationElement
            Return New EndpointDefinition With {.Url = elementName}
        End Function

        Protected Overrides Function GetElementKey(element As ConfigurationElement) As Object
            Return DirectCast(element, EndpointDefinition).Url
        End Function

        Public Overrides ReadOnly Property CollectionType As ConfigurationElementCollectionType
            Get
                Return ConfigurationElementCollectionType.AddRemoveClearMap
            End Get
        End Property

        Public Shadows Property Item(index As Integer) As EndpointDefinition
            Get
                Return CType(BaseGet(index), EndpointDefinition)
            End Get
            Set(value As EndpointDefinition)
                If Not (BaseGet(index) Is Nothing) Then
                    BaseRemoveAt(index)
                End If
                BaseAdd(index, value)
            End Set
        End Property
    End Class
  • 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-06-11T04:15:51+00:00Added an answer on June 11, 2026 at 4:15 am

    Your problem here is that your class implements IEnumerable, and not IEnumerable(Of T).

    Since EndpointCollection inherits ConfigurationElementCollection and ConfigurationElementCollection implements IEnumerable, you can use the OfType() extension method (or Cast(), if you want).

    So you should be able to do the following:

    Dim Endpoints = MyConfigSection.InitialEndpoints.OfType(Of Endpointdefinition).OrderBy(function(x) x.Priority)
    

    or

    Dim Endpoints = MyConfigSection.InitialEndpoints.Cast(Of Endpointdefinition).OrderBy(function(x) x.Priority)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.