blob: 0b07f800ea20d30a8faf025bee6f828619341f84 (
plain) (
blame)
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
|
using System;
namespace IrcTokens
{
/// <summary>
/// Represents the three parts of a hostmask. Parse with the constructor.
/// </summary>
public class Hostmask
{
public string NickName { get; set; }
public string UserName { get; set; }
public string HostName { get; set; }
public override string ToString() => _source;
public override int GetHashCode() => _source.GetHashCode(StringComparison.Ordinal);
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
return _source == ((Hostmask) obj)._source;
}
private readonly string _source;
public Hostmask(string source)
{
if (source == null) return;
_source = source;
if (source.Contains('@', StringComparison.Ordinal))
{
var split = source.Split('@');
NickName = split[0];
HostName = split[1];
}
else
{
NickName = source;
}
if (NickName.Contains('!', StringComparison.Ordinal))
{
var userSplit = NickName.Split('!');
NickName = userSplit[0];
UserName = userSplit[1];
}
}
}
}
|