Skip to content

Commit

Permalink
ch: update the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Winner-Timothy Bolorunduro committed Feb 15, 2024
1 parent afb3b4b commit a3272a1
Showing 1 changed file with 25 additions and 49 deletions.
74 changes: 25 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# vCardLib

[![Build status](https://ci.appveyor.com/api/projects/status/3olgly7hvi6vfnsu/branch/master?svg=true)](https://ci.appveyor.com/project/BolorunduroWinnerTimothy/vcardlib/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/bolorundurowb/vCardLib/badge.svg?branch=master)](https://coveralls.io/github/bolorundurowb/vCardLib?branch=master) [![NET Standard](https://img.shields.io/badge/netstandard-2.0-ff66b6.svg)]() [![NuGet Badge](https://buildstats.info/nuget/vcardlib.dll)](https://www.nuget.org/packages/vCardLib.dll) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/bolorundurowb/vCardLib/badge.svg?branch=master)](https://coveralls.io/github/bolorundurowb/vCardLib?branch=master) [![NET Standard](https://img.shields.io/badge/netstandard-1.3-ff66b6.svg)]() [![NuGet Badge](https://buildstats.info/nuget/vcardlib.dll)](https://www.nuget.org/packages/vCardLib.dll) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

<br/>

**NOTE: A major redesign is coming using current C# features and with stricter compliance with the RFC-6350 and RFC-2426
standards. feel free to check
the [massive-rewrite-v5](https://github.com/bolorundurowb/vCardLib/tree/feature/massive-rewrite-v5) branch out**
This `master` branch contains the latest changes and features (which are breaking) to see the last major release (
v4) click [here](https://github.com/bolorundurowb/vCardLib/tree/v4)

<br/>

This `master` branch contains the latest changes and features (which may be breaking) to see the last major release (
v3) click [here](https://github.com/bolorundurowb/vCardLib/tree/v3)

T this library supports reading multiple contacts from a single vcf file, a stream or a contact string and returns the
contact objects in a List. The library currently **supports only vCard version 2.1 and 3.0** (a curated list of
This library supports reading multiple contacts from a single vcf file, a stream or a contact string and returns the
contact objects in an `Enumerable`. The library currently **supports only vCard version 2.1 and 3.0** (a curated list of
properties supported can be seen on the documentation site).

#### How to use the library:
Expand All @@ -38,14 +31,14 @@ dotnet add package vCardLib.dll

```csharp
string filePath = // path to vcf file;
var contacts = Deserializer.FromFile(filePath);
IEnumerable<vCard> contacts = vCardDeserializer.FromFile(filePath);
```

### Deserialize from a Stream

```csharp
var stream = // generate stream containing serialized vcards
var contacts = Deserializer.FromStream(stream);
IEnumerable<vCard> contacts = vCardDeserializer.FromStream(stream);
```

### Deserialize from a string
Expand All @@ -55,66 +48,49 @@ var contactDetails = @"BEGIN:VCARD
VERSION:2.1
N:John;Doe;;;
END:VCARD";
var contacts = Deserializer.FromString(contactDetails);
IEnumerable<vCard> contacts = vCardDeserializer.FromContent(contactDetails);
```

All deserialization produces a `vCardCollection` containing the successfully deserialized contact information that can be iterated over. Iterate over the contact collection and pick the vCard objects:

```csharp
foreach(var contact in contacts)
{
Console.WriteLine(contact.FormattedName);
}
```

## For Serialization

### Serialize as string

```csharp
var vcard = new vCard
var vcard = new vCard(vCardVersion.v2)
{
Version = vCardVersion.V2,
FormattedName = "John Doe",
BirthPlace = "Antarctica",
Gender = GenderType.Other,
GivenName = "John",
MiddleName = "Adekunle",
FamilyName = "Doe"
FormattedName = "John Doe"
};
var serialized = Serializer.Serialize(vcard);
var serialized = vCardSerializer.Serialize(vcard);

/*
BEGIN:VCARD
VERSION:2.1
REV:20230719T001838Z
N:Doe;John;Adekunle;;
FN:John Doe
BIRTHPLACE:Antarctica
KIND:Individual
GENDER:Other
END:VCARD
*/
```

### Serialize to a Stream
### Serialize with an override

This allows a vcard to get serialized to a different version

```csharp
var ms = new MemoryStream();
var vcard = new vCard
var vcard = new vCard(vCardVersion.v2)
{
Version = vCardVersion.V2,
FormattedName = "John Doe",
BirthPlace = "Antarctica",
Gender = GenderType.Other,
GivenName = "John",
MiddleName = "Adekunle",
FamilyName = "Doe"
FormattedName = "John Doe"
};
await Serializer.SerializeToStream(vcard, ms);
var serialized = vCardSerializer.Serialize(vcard, vCardVersioon.v4);

/*
BEGIN:VCARD
VERSION:4.0
REV:20230719T001838Z
FN:John Doe
END:VCARD
*/
```

There is support for serializing a collection of `vCard` as well with overloads to the `Serialize` and `SerializeToStream` methods.

## Contributors

Expand Down

0 comments on commit a3272a1

Please sign in to comment.