Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Configuration - List of key/values without using custom section

Configuration - List of key/values without using custom section

Scheduled Pinned Locked Moved C#
tutorialquestionworkspace
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BillyGoatGruff
    wrote on last edited by
    #1

    I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks

    M realJSOPR B 3 Replies Last reply
    0
    • B BillyGoatGruff

      I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.

      Never underestimate the power of human stupidity RAH

      B 2 Replies Last reply
      0
      • M Mycroft Holmes

        I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.

        Never underestimate the power of human stupidity RAH

        B Offline
        B Offline
        BillyGoatGruff
        wrote on last edited by
        #3

        Hi, Thanks for the suggestion. Unfortuantely using a database is not really viable for this particular problem, as some of the components involved are deployed at customers' premises. I don't want to add the complexity of deploying a database engine etc. Thanks, Rob.

        1 Reply Last reply
        0
        • M Mycroft Holmes

          I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.

          Never underestimate the power of human stupidity RAH

          B Offline
          B Offline
          BillyGoatGruff
          wrote on last edited by
          #4

          Ahhh... I've just re-read your post. Properly this time :-O Do you think it is possible to use a datatable as a Type for a custom config section? The solution is quite committed to using app.config and System.Configuration. I wouldn't want to have to have a second xml file containing the serialised datatable - so I'd need to get it into app.config somehow... Thanks again, Rob.

          1 Reply Last reply
          0
          • B BillyGoatGruff

            I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            LINQ to XML would work, and you could write/read your own file without worrying about messing up or dealing with multiple app.config files. I'd probably create a class lib project that you can use in multiple assemblies. Shouldn't be too hard to come up with something usable and flexible.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            1 Reply Last reply
            0
            • B BillyGoatGruff

              I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks

              B Offline
              B Offline
              BillyGoatGruff
              wrote on last edited by
              #6

              Thanks for all your suggestions. I have decided on the following: Declare a section in app.config ilke this:

              The section then utilised like this: a1 b1 c1 and then accessed in code like this: System.Configuration.ClientSettingsSection sect = (System.Configuration.ClientSettingsSection)System.Configuration.ConfigurationManager.GetSection("SecondaryIdentifiersSect"); foreach (System.Configuration.SettingElement e in sect.Settings) { System.Diagnostics.Debug.WriteLine(e.Name); System.Diagnostics.Debug.WriteLine(e.Value.ValueXml.InnerText); }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups