Solved

Application and user settings read value in visual studio

Posted on 2014-09-17
8
136 Views
Last Modified: 2014-11-27
Hi EE,

    I want to change our current way of reading application setting from a text file on disk to have those settings stored in app.config file.
   
   I wrote a class 'TXSettings' which has 100 properties that I'm intending to use to get all the application settings.
 
   I call a 'Load' method upon project startup

 Public Shared Function Load1() As TXSettings

        Dim settings As New TXSettings
        With settings
            .SpeedUnit = My.Settings.SpeedUnit
            .UpgradeRequired = My.Settings.UpgradeRequired
            ......   'The next 98 properties
        End With
        Return settings
    End Function

Open in new window


as you can see the load method will have something like above, is there a cleaner way of doing this? like a loop thru or something else?
0
Comment
Question by:miketonny
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:Akilandeshwari N
Comment Utility
0
 
LVL 2

Author Comment

by:miketonny
Comment Utility
hi @Akilandeshwari N,

   how do you do this with an object class? I know System.Reflection and loop through all properties in a class but I don't want to use reflection
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
Why should you use a custom class to get the settings? My.Settings is already a class that does it for you.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Author Comment

by:miketonny
Comment Utility
@JamesBurger,
I haven't tried, but can i bind the datacontext of a window to my.settings?

my planning is to create a 'setting' window for user to view and edit the current setting of the application, with wpf databinding to a class that's real easy.

or is this the correct way of doing this?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
I could not say in WPF, my expertise is in Windows Forms Applications. In that environment, yes, you can bind controls to My.Settings just as you can with almost any class in the application.
0
 
LVL 2

Author Comment

by:miketonny
Comment Utility
thank you for your suggestion
I've found some resources on google showing me  how to bind settings in wpf, gonna try it tomorrow
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now