VcfSerialize Method

Serializes a collection of VCard objects into a Stream using the VCF format.

Definition

Namespace: FolkerKinzel.VCards
Assembly: FolkerKinzel.VCards (in FolkerKinzel.VCards.dll) Version: 8.0.1+a91cc3f0fd39aeb548e16006a60ca9dd10a304a2
C#
public static void Serialize(
	IEnumerable<VCard?> vCards,
	Stream stream,
	VCdVersion version = VCdVersion.V3_0,
	ITimeZoneIDConverter? tzConverter = null,
	VcfOpts options = VcfOpts.Default,
	bool leaveStreamOpen = false
)

Parameters

vCards  IEnumerableVCard
The VCard objects to be serialized. The collection may be empty or may contain null values.
stream  Stream
A Stream into which the serialized VCard objects are written.
version  VCdVersion  (Optional)
The vCard version used for the serialization.
tzConverter  ITimeZoneIDConverter  (Optional)
An object that implements ITimeZoneIDConverter to convert IANA time zone names to UTC offsets, or null.
options  VcfOpts  (Optional)
Options for serializing VCF. The flags can be combined.
leaveStreamOpen  Boolean  (Optional)
true means that stream will not be closed by the method. The default value is false to close stream when the method returns.

Remarks

  Caution

Although the method itself is thread-safe, the VCard objects passed to the method are not. Block read and write access to these VCard objects, while this method is being executed!

The method may serialize more vCards than were originally elements in the argument vCards. This happens when a VCF file is saved as vCard 4.0 and when in the properties Members or Relations of a VCard object further VCard objects can be found.

In the same way the method behaves, if a vCard 2.1 or 3.0 is serialized with the option AppendAgentAsSeparateVCard and if in the Relations property of a VCard object an instance is located on whose RelationType parameter the Agent flag is set.

Exceptions

ArgumentNullExceptionstream or vCards is null.
ArgumentExceptionstream does not support write operations.
ArgumentOutOfRangeExceptionversion is not a defined value of the VcfOpts enum.
IOExceptionI/O error.
ObjectDisposedExceptionstream was already closed.

See Also