I know it’s the XML age out there, but if I would like to make a simple properties file for using in a small application, XML Parsers, XST, XSL, XSD, and all these ‘X’ techs make a mess in my head. A minimalist “ini like” flat text file for store properties still missing in .net/mono API.
So, props.dll is a .NET/Mono library for simple and minimal parameters files manipulation. The format of these files are simplest than the MS Windows .ini files. The philosophy of key=value still exists except the “sections”. All keys in the file belong to one anonymous section. Comments etc. in the file are not allowed. Of course the file has unicode encoding.
Also, from the version 1.2 you can read and write priperties encoded by the base64 formula
The library is open source software and distributed under the terms & conditions of the FreeBSD License.
Download Library (dll) Library Reference Checkout Source
Change log
Version 1.2:
- Added SetPropertyEncoded method for read & decode Base64 formula encoded properties.
- Added GetPropertyDecoded method for write properties to files, encoded with Base64 formula.
- Added overloaded GetPropertyDecoded method with emptyStrInsteadNull parameter to select the returned value (empty string or null) in case of key not found.
- Added overloaded GetProperty method with emptyStrInsteadNull parameter to select the returned value (empty string or null) in case of key not found.
Version 1.1
- DelProperty method now returns true if done / false if key not found
- GetProperty method becomes case insensitive in key search
- DLL’s filename changes to be consistent with Microsoft Design Guidelines
Version 1.0
- The initial version of the library
Quick Reference (for more info see full library’s reference)
Public Member Functions
Props (string file, bool autosave)
→ Constructor of the class, with default separator ‘=’ of key-value
Props (string file, bool autosave, string separator)
→ Constructor of the class, with optional key-value separator
void Save ()
→ Save pairs of values and keys at properites file
string GetProperty (string key)
→ Returns the value of the specified key (search is case insensitive)
string GetProperty (string key, bool emptyStrInsteadNull)
→ Returns the value of the specified key (search is case insensitive, emptyStrInsteadNull specify the return value (empty string or null) in case of key not found
string GetPropertyDecoded (string key)
→ Returns the value of the specified key (search is case insensitive), decoded from Base64 formula, null returned if key not found
string GetPropertyDecoded (string key, bool emptyStrInsteadNull)
→ Returns the value of the specified key (search is case insensitive), decoded from Base64 formula, emptyStrInsteadNull specify the return value (empty string or null) in case of key not found
void SetProperty (string key, string val)
→ Sets the specified value to the key. If key not exist, creating it and store the value.
void SetPropertyEncoded (string key, string val)
→ Sets the specified value to the key, encoded with Base64 formula. If key not exist, creating it and store the value.
bool DelProperty (string key)
→ Removes the specified key. If not exist do nothing.
Public Attributes
const bool NO_AUTOSAVE = false
const bool AUTOSAVE = true