Class FinContactFolder

Namespace
Subsembly.FinTS
Assembly
Subsembly.FinTS.Core.dll

Simple file system based management of persistent FinContact objects.

public sealed class FinContactFolder : IFinContactFolder, IEnumerable
Inheritance
FinContactFolder
Implements
Inherited Members

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.

public FinContactFolder(string sContactsPath, string sSuffix)

Parameters

sContactsPath string

Directory where all the contact XML files are stored. Must not be null.

sSuffix string

Optional suffix that shall be used for the stored contact files. If null, then the suffix .xml will be used. If this is an empty string, then no suffix will be appended.

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

ArgumentNullException

The parameter sContactsPath was null.

Properties

ContactsPath

Provides the file system path where the contacts are stored.

public string ContactsPath { get; }

Property Value

string

Count

Provides the count of contacts stored in this folder.

public int Count { get; }

Property Value

int

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.

public string Suffix { get; }

Property Value

string

Methods

Add(FinContact)

Adds another contact to this FinContactFolder instance and stores it.

public void Add(FinContact aContact)

Parameters

aContact FinContact

FinContact instance to be added and stored. Must not be null, and must not have already been added to this FinContactFolder instance.

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

ArgumentNullException

The contact parameter was null.

InvalidOperationException

The given contact is already managed by this class.

FindContact(string)

Finds a contact with a given name.

public FinContact FindContact(string sContactName)

Parameters

sContactName string

The name of the contact to find. Must not be null.

Returns

FinContact

If a contact with the given name is found, then it is returned. If no such contact is found then null is returned.

GetEnumerator()

public IEnumerator GetEnumerator()

Returns

IEnumerator

Refresh()

public void Refresh()

Remove(FinContact)

Removes a contact from this FinContactFolder instance and deletes it.

public void Remove(FinContact aContact)

Parameters

aContact FinContact

FinContact instance to be removed and deleted. Must not be null. The FinContact instance must be managed by this FinContactFolder instance.

Exceptions

ArgumentNullException

The given contact reference was null.

InvalidOperationException

The given contact is not managed by this class.

Update(FinContact)

public void Update(FinContact aContact)

Parameters

aContact FinContact