|
|
Settings
|
[SerializableAttribute] public class SettingsCollection : Dictionary<string, string>
The SettingsCollection type exposes the following members.
| Name | Description | |
|---|---|---|
| SettingsCollection | Initializes a new instance of the SettingsCollection class. | |
| SettingsCollection(IDictionaryString, String) | Initializes a new instance of the SettingsCollection class. | |
| SettingsCollection(IEqualityComparerString) | Initializes a new instance of the SettingsCollection class. | |
| SettingsCollection(IDictionaryString, String, IEqualityComparerString) | Initializes a new instance of the SettingsCollection class. |
| Name | Description | |
|---|---|---|
| Comparer | Gets the IEqualityComparerT that is used to determine equality of keys for the dictionary. (Inherited from DictionaryString, String) | |
| Count | Gets the number of key/value pairs contained in the DictionaryTKey, TValue. (Inherited from DictionaryString, String) | |
| Item | Gets or sets the value associated with the specified key. (Inherited from DictionaryString, String) | |
| Keys | Gets a collection containing the keys in the DictionaryTKey, TValue. (Inherited from DictionaryString, String) | |
| Validation | Gets the ValidationService object used to perform validation on the Values. | |
| Values | Gets a collection containing the values in the DictionaryTKey, TValue. (Inherited from DictionaryString, String) |
| Name | Description | |
|---|---|---|
| Add | Adds the specified key and value to the dictionary. (Inherited from DictionaryString, String) | |
| Clear | Removes all keys and values from the DictionaryTKey, TValue. (Inherited from DictionaryString, String) | |
| ContainsKey | Determines whether the DictionaryTKey, TValue contains the specified key. (Inherited from DictionaryString, String) | |
| ContainsValue | Determines whether the DictionaryTKey, TValue contains a specific value. (Inherited from DictionaryString, String) | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) | |
| GetEnumerator | Returns an enumerator that iterates through the DictionaryTKey, TValue. (Inherited from DictionaryString, String) | |
| GetHashCode | Serves as the default hash function. (Inherited from Object) | |
| GetObjectData | Implements the ISerializable interface and returns the data needed to serialize the DictionaryTKey, TValue instance. (Inherited from DictionaryString, String) | |
| GetType | Gets the Type of the current instance. (Inherited from Object) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) | |
| OnDeserialization | Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. (Inherited from DictionaryString, String) | |
| Remove | Removes the value with the specified key from the DictionaryTKey, TValue. (Inherited from DictionaryString, String) | |
| ToString |
Gets the String representation of SettingsCollection.
(Overrides ObjectToString) | |
| TryAdd | Adds an element with the specified key and value if an element is not present with the specified key. | |
| TryGetValue | Gets the value associated with the specified key. (Inherited from DictionaryString, String) |
| Name | Description | |
|---|---|---|
| (SettingsCollection to String) | Implicitly converts SettingsCollection to a String. | |
| (String to SettingsCollection) | Implicitly converts String to SettingsCollection. |
| Name | Description | |
|---|---|---|
| GetEnumValueOrDefault |
Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
| GetEnumValueOrDefaultT |
Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) |
using System; using System.Collections.Generic; using GSF.Collections; using GSF.Validation; class Program { static void Main(string[] args) { // Initialize settings. SettingsCollection settings = "Server=localhost;Port=5000"; // Add validation rules. settings.Validation.AddValidation("Server", new NonNullStringValidator()); settings.Validation.AddValidation("Port", new NonNullStringValidator()); settings.Validation.AddValidation("Port", new NumericRangeValidator(1000, 2000)); // Validate settings. string errors; if (!settings.Validation.Validate(out errors)) { // Show validation errors. Console.WriteLine(string.Format("Settings: {0}\r\n", settings)); Console.WriteLine(errors); } else { // Show stored settings. foreach (KeyValuePair<string, string> setting in settings) { Console.WriteLine(string.Format("Key={0}; Value={1}", setting.Key, setting.Value)); } } Console.ReadLine(); } }