-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PBE-537] Possibility to send system messages (#126)
* Possibility to send system messages * wip: created MessageRequestType enum * Remove invalid MessageRequestType values + Add StringEnumConverter * Add default regular message type + ignore default values during serialization --------- Co-authored-by: Daniel Sierpiński <33436839+sierpinskid@users.noreply.github.com>
- Loading branch information
1 parent
0e0b195
commit 44e5cb4
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
|
||
namespace StreamChat.Utils | ||
{ | ||
public static class Utils | ||
{ | ||
/// <summary> | ||
/// Return enum value string representation respecting optional <see cref="EnumMemberAttribute"/> that overrides string representation | ||
/// </summary> | ||
public static string ToEnumMemberString<T>(this T value) | ||
where T : Enum | ||
{ | ||
return typeof(T) | ||
.GetTypeInfo() | ||
.DeclaredMembers | ||
.SingleOrDefault(x => x.Name == value.ToString()) | ||
?.GetCustomAttribute<EnumMemberAttribute>(false) | ||
?.Value ?? value.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters