C# Class DotNet.Config.AppSettings

This class uses a java style .properties file to load, apply ('glue'), and save settings. I've found this approach and helper class is far easier than using app.config for several reasons: 1) Non-technical folks have no problem editing .ini "name=value" style files, but they struggle with XML 2) Values with quotes in xml are a headache - you have to use '"' which gets messy 3) If you're writing a packaged dll, it needs to use the entry point's app.config which we don't control. Using this approach, you can ship a 'MyDll.config' 4) The 'glueOn' approach is really handy. It'll just stick values from the .properties file onto your class, regardless of whether they're public, private, or static. If you use a 'private static string _name' convention, it'll even take 'name=value' from the properties file (no underscore) and apply it 5) Saving settings back to app.config is a royal headache. Here, you just call Save(name, value) and it's done This class also takes into account loading the properties file from the same directory as the executing assembly, even when installed as a service, so you don't run into the issue of the current path being sys32 or whatever execution location services are started from.
Show file Open project: jknight/DotNet.Config

Public Properties

Property Type Description
CacheCount int

Public Methods

Method Description
GetAssemblyDirectory ( ) : string
GlueOnto ( object o ) : void

Uses the default 'config.properties' file

GlueOnto ( object o, string configFile ) : void
Retrieve ( ) : string>.Dictionary
Retrieve ( string configFile ) : string>.Dictionary
Save ( String name, String value ) : void

NOT WELL TESTED.

Private Methods

Method Description
_Retrieve ( string configFile ) : string>.Dictionary

Method Details

GetAssemblyDirectory() public static method

public static GetAssemblyDirectory ( ) : string
return string

GlueOnto() public static method

Uses the default 'config.properties' file
public static GlueOnto ( object o ) : void
o object
return void

GlueOnto() public static method

public static GlueOnto ( object o, string configFile ) : void
o object
configFile string
return void

Retrieve() public static method

public static Retrieve ( ) : string>.Dictionary
return string>.Dictionary

Retrieve() public static method

public static Retrieve ( string configFile ) : string>.Dictionary
configFile string
return string>.Dictionary

Save() public static method

NOT WELL TESTED.
public static Save ( String name, String value ) : void
name String
value String
return void

Property Details

CacheCount public static property

public static int CacheCount
return int