-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CONTENT_APPEND and CONTENT_SHAPE messages; displays table con…
…tent via Collection content type
- Loading branch information
1 parent
29a1181
commit a4865d2
Showing
19 changed files
with
219 additions
and
178 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
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,48 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Utils.Commands; | ||
|
||
/// <summary> | ||
/// Describes an asynchronous command that can be executed only in specified context. | ||
/// </summary> | ||
public sealed class AsyncContextCommand : ICommand | ||
{ | ||
private readonly Func<object?, Task> _execute; | ||
|
||
/// <summary> | ||
/// Valid execution context. | ||
/// </summary> | ||
public HashSet<object> ExecutionContext { get; } = new(); | ||
|
||
public event EventHandler? CanExecuteChanged; | ||
|
||
public AsyncContextCommand(Func<object?, Task> execute) => _execute = execute ?? throw new ArgumentNullException(nameof(execute)); | ||
|
||
/// <summary> | ||
/// Raises <see cref="CanExecuteChanged" /> event in a synchronization context-bound thread. | ||
/// </summary> | ||
public void OnCanBeExecutedChanged() | ||
{ | ||
if (CanExecuteChanged != null) | ||
{ | ||
if (SynchronizationContext.Current == null && UI.Scheduler != null) | ||
{ | ||
Task.Factory.StartNew( | ||
() => CanExecuteChanged(this, EventArgs.Empty), | ||
CancellationToken.None, | ||
TaskCreationOptions.None, | ||
UI.Scheduler); | ||
} | ||
else | ||
{ | ||
CanExecuteChanged(this, EventArgs.Empty); | ||
} | ||
} | ||
} | ||
|
||
public bool CanExecute(object? parameter) => parameter != null && ExecutionContext.Contains(parameter); | ||
|
||
public void Execute(object? parameter) => _execute(parameter); | ||
|
||
public Task ExecuteAsync(object? parameter) => _execute(parameter); | ||
} |
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
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
Oops, something went wrong.