Class DictionaryExtensions
Inheritance
System.Object
DictionaryExtensions
Namespace: Lucene.Net.Support
Assembly: Lucene.Net.dll
Syntax
public static class DictionaryExtensions : object
Methods
| Improve this Doc View SourceLoad(IDictionary<String, String>, Stream)
Loads properties from the specified
Declaration
public static void Load(this IDictionary<string, string> dict, Stream input)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System. |
dict | This dictionary. |
Stream | input | The |
Remarks
The Properties file is interpreted according to the following rules:
- Empty lines are ignored.
- Lines starting with either a "#" or a "!" are comment lines and are ignored.
- A backslash at the end of the line escapes the following newline character ("\r", "\n", "\r\n"). If there's a whitespace after the backslash it will just escape that whitespace instead of concatenating the lines. This does not apply to comment lines.
- A property line consists of the key, the space between the key and the value, and the value. The key goes up to the first whitespace, "=" or ":" that is not escaped. The space between the key and the value contains either one whitespace, one "=" or one ":" and any number of additional whitespaces before and after that character. The value starts with the first character after the space between the key and the value.
- Following escape sequences are recognized: "\ ", "\", "\r", "\n", "!", "#", "\t", "\b", "\f", and "\uXXXX" (unicode character).
This method is to mimic and interoperate with the Properties class in Java, which is essentially a string dictionary that natively supports importing and exporting to this format.
Put<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)
Declaration
public static TValue Put<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dict | |
TKey | key | |
TValue | value |
Returns
Type | Description |
---|---|
TValue |
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
PutAll<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>)
Declaration
public static void PutAll<TKey, TValue>(this IDictionary<TKey, TValue> dict, IEnumerable<KeyValuePair<TKey, TValue>> kvps)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dict | |
IEnumerable<Key |
kvps |
Type Parameters
Name | Description |
---|---|
TKey | |
TValue |
Store(IDictionary<String, String>, Stream, String)
Stores the mappings in this Properties to the specified
Declaration
public static void Store(this IDictionary<string, string> dict, Stream output, string comments)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System. |
dict | This dictionary. |
Stream | output | The output |
System. |
comments | The comments to put at the beginning. |