Menu

[r40]: / trunk / WhatsappClient / Classes / Contact.cs  Maximize  Restore  History

Download this file

61 lines (53 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* by Stefan Bijen aka Freakypain - stefan.bijen@gmail.com
* by Swen Kooij aka Kirk - swenkooij@gmail.com
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
/// <summary>
/// Represents a contact
/// </summary>
public class Contact
{
/// <summary>
/// The phone number belonging to this account.
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// The country code
/// </summary>
public string CountryCode { get; set; }
/// <summary>
/// The name of the contact
/// </summary>
public string Name { get; set; }
/// <summary>
/// Initiliazes the class.
/// </summary>
/// <param name="_PhoneNumber">Phonenumber without country code</param>
/// <param name="_CountryCode">The country code in + format, eg, +31</param>
/// <param name="_Name">The name of the contact person</param>
public Contact(string _PhoneNumber, string _CountryCode, string _Name)
{
// Make global
PhoneNumber = _PhoneNumber;
CountryCode = _CountryCode;
Name = _Name;
// Checks
if (isValidPhoneNumber() == false) throw new Exception("Phone number is invalid format. Make sure it's without the country code.");
if (CountryCode.Contains("+") == false) throw new Exception("Country code is invalid.");
}
/// <summary>
/// Checks if the phone number is valid.
/// </summary>
/// <param name="_Phonenumber">The full phone umber, including country code.</param>
private bool isValidPhoneNumber()
{
if (PhoneNumber.Contains("+"))
return false;
return true;
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.