Class FinContactFolder
Simple file system based management of persistent FinContact objects.
Inheritance
Inherited Members
Namespace: Subsembly.FinTS
Assembly: Subsembly.FinTS.Core.dll
Syntax
public sealed class FinContactFolder : IFinContactFolder, IEnumerable
Remarks
This class manages persistent FinContact objects by storing them in a given directory. Each FinContact object is stored in its own XML file. Thus the list of all contacts available is determined by scanning the files of the given directory.
The filename for storing contact files is made up by using the given contact name
plus a .xml
suffix. Also, when loading contact files, if the contact does not
have a ContactName attribute then its ContactName will be derived from its filename
by removing the .xml
suffix.
Constructors
FinContactFolder(String, String)
Creates a new instance of FinContactFolder for a particular file system folder.
Declaration
public FinContactFolder(string sContactsPath, string sSuffix)
Parameters
Type | Name | Description |
---|---|---|
System.String | sContactsPath | Directory where all the contact XML files are stored. Must not be |
System.String | sSuffix | Optional suffix that shall be used for the stored contact files. If |
Remarks
Ideally the indicated directory shall be dedicated for the sole purpose of storing FinContact objects managed by this class, and shall not contain any other files.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter sContactsPath was |
Properties
ContactsPath
Provides the file system path where the contacts are stored.
Declaration
public string ContactsPath { get; }
Property Value
Type | Description |
---|---|
System.String |
Count
Provides the count of contacts stored in this folder.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
The returned value may be out of date, because it is not updated whenever this property is read, but only when contacts are added or removed. Thus, if stored contact files have been added or deleted through other means, this is not reflected by this property. Use the method Refresh() in order to refresh the contact list from the file system.
Suffix
Provides the file name suffix applied to the stored contacts.
Declaration
public string Suffix { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
Add(FinContact)
Adds another contact to this FinContactFolder instance and stores it.
Declaration
public void Add(FinContact aContact)
Parameters
Type | Name | Description |
---|---|---|
FinContact | aContact | FinContact instance to be added and stored. Must not be |
Remarks
The filename used to store the contact is derived from the ContactName property of the given contact. If no ContactName was set, then the ContactGuid is used as the filename.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The contact parameter was |
System.InvalidOperationException | The given contact is already managed by this class. |
FindContact(String)
Finds a contact with a given name.
Declaration
public FinContact FindContact(string sContactName)
Parameters
Type | Name | Description |
---|---|---|
System.String | sContactName | The name of the contact to find. Must not be |
Returns
Type | Description |
---|---|
FinContact | If a contact with the given name is found, then it is returned. If no such
contact is found then |
GetEnumerator()
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |
Refresh()
Declaration
public void Refresh()
Remove(FinContact)
Removes a contact from this FinContactFolder instance and deletes it.
Declaration
public void Remove(FinContact aContact)
Parameters
Type | Name | Description |
---|---|---|
FinContact | aContact | FinContact instance to be removed and deleted. Must not be
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The given contact reference was |
System.InvalidOperationException | The given contact is not managed by this class. |
Update(FinContact)
Declaration
public void Update(FinContact aContact)
Parameters
Type | Name | Description |
---|---|---|
FinContact | aContact |