mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-22 19:04:59 +00:00
refactor: simplify user string conversion
This commit is contained in:
parent
05e3f0e5b8
commit
37f8049521
3 changed files with 6 additions and 4 deletions
|
@ -81,8 +81,5 @@ namespace SourceGit.Converters
|
||||||
|
|
||||||
public static readonly FuncValueConverter<string, bool> ContainsSpaces =
|
public static readonly FuncValueConverter<string, bool> ContainsSpaces =
|
||||||
new FuncValueConverter<string, bool>(v => v != null && v.Contains(' '));
|
new FuncValueConverter<string, bool>(v => v != null && v.Contains(' '));
|
||||||
|
|
||||||
public static readonly FuncValueConverter<Models.User, string> UserToString =
|
|
||||||
new FuncValueConverter<Models.User, string>(v => v == null ? string.Empty : $"{v.Name} <{v.Email}>");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,11 @@ namespace SourceGit.Models
|
||||||
return _caches.GetOrAdd(data, key => new User(key));
|
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>();
|
private static ConcurrentDictionary<string, User> _caches = new ConcurrentDictionary<string, User>();
|
||||||
private readonly int _hash;
|
private readonly int _hash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
<Grid Grid.Column="1"
|
<Grid Grid.Column="1"
|
||||||
ColumnDefinitions="20,*"
|
ColumnDefinitions="20,*"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ToolTip.Tip="{Binding Author, Converter={x:Static c:StringConverters.UserToString}}">
|
ToolTip.Tip="{Binding Author}">
|
||||||
<v:Avatar Grid.Column="0"
|
<v:Avatar Grid.Column="0"
|
||||||
Width="16" Height="16"
|
Width="16" Height="16"
|
||||||
Margin="4,0,0,0"
|
Margin="4,0,0,0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue