forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.cs
More file actions
34 lines (27 loc) · 909 Bytes
/
Copy pathUser.cs
File metadata and controls
34 lines (27 loc) · 909 Bytes
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
using System.Collections.Concurrent;
namespace SourceGit.Models
{
public class User
{
public static readonly User Invalid = new User(string.Empty);
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public User(string data)
{
var parts = data.Split('±', 2);
if (parts.Length < 2)
parts = [string.Empty, data];
Name = parts[0];
Email = parts[1].TrimStart('<').TrimEnd('>');
}
public static User FindOrAdd(string data)
{
return _caches.GetOrAdd(data, key => new User(key));
}
public override string ToString()
{
return $"{Name} <{Email}>";
}
private static ConcurrentDictionary<string, User> _caches = new ConcurrentDictionary<string, User>();
}
}