project: reorganize the structure of the project.

* remove dotnet-tool.json because the project does not rely on any dotnet tools.
* remove Directory.Build.props because the solution has only one project.
* move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
leo 2024-04-02 20:00:33 +08:00
parent 96e60da7ad
commit 96d4150d26
319 changed files with 37 additions and 53 deletions

46
src/Models/User.cs Normal file
View file

@ -0,0 +1,46 @@
using System.Collections.Generic;
namespace SourceGit.Models
{
public class User
{
public static readonly User Invalid = new User();
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public override bool Equals(object obj)
{
if (obj == null || !(obj is User))
return false;
var other = obj as User;
return Name == other.Name && Email == other.Email;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public static User FindOrAdd(string data)
{
if (_caches.TryGetValue(data, out var value))
{
return value;
}
else
{
var nameEndIdx = data.IndexOf('<', System.StringComparison.Ordinal);
var name = nameEndIdx >= 2 ? data.Substring(0, nameEndIdx - 1) : string.Empty;
var email = data.Substring(nameEndIdx + 1);
User user = new User() { Name = name, Email = email };
_caches.Add(data, user);
return user;
}
}
private static Dictionary<string, User> _caches = new Dictionary<string, User>();
}
}