-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented a bunch of base message types with static instances store…
…d to avoid useless allocations and make code more fluent
- Loading branch information
1 parent
dd168e6
commit 4e5835d
Showing
7 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace MVVMToolkit.Messaging | ||
{ | ||
public abstract class BaseTagMessage<TType> where TType : new() | ||
{ | ||
private static readonly TType Instance = new(); | ||
|
||
public static TType Message() => Instance; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
namespace MVVMToolkit.Messaging | ||
{ | ||
public abstract class BaseValueMessage<TValue> | ||
{ | ||
public TValue value; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace MVVMToolkit.Messaging | ||
{ | ||
public class CloseViewsMessage { } | ||
public class CloseViewsMessage : BaseTagMessage<CloseViewsMessage> { } | ||
} |
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,14 @@ | ||
namespace MVVMToolkit.Messaging | ||
{ | ||
public abstract class ValueMessage<TType, TValue> : BaseValueMessage<TValue> | ||
where TType : BaseValueMessage<TValue>, new() | ||
{ | ||
private static readonly TType Instance = new(); | ||
|
||
public static TType Message(TValue value) | ||
{ | ||
Instance.value = value; | ||
return Instance; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.