refactor(app): compose live presentation startup
This commit is contained in:
parent
aa6ffa5176
commit
88f32dc4e2
23 changed files with 1767 additions and 626 deletions
|
|
@ -21,4 +21,31 @@ internal sealed class LiveEntityRuntimeSlot : ILiveEntityRuntimeSource
|
|||
throw new InvalidOperationException("The live entity runtime is already bound.");
|
||||
Current = runtime;
|
||||
}
|
||||
|
||||
public IDisposable BindOwned(LiveEntityRuntime runtime)
|
||||
{
|
||||
Bind(runtime);
|
||||
return new Binding(this, runtime);
|
||||
}
|
||||
|
||||
private void Unbind(LiveEntityRuntime expected)
|
||||
{
|
||||
if (ReferenceEquals(Current, expected))
|
||||
Current = null;
|
||||
}
|
||||
|
||||
private sealed class Binding : IDisposable
|
||||
{
|
||||
private LiveEntityRuntimeSlot? _owner;
|
||||
private readonly LiveEntityRuntime _expected;
|
||||
|
||||
public Binding(LiveEntityRuntimeSlot owner, LiveEntityRuntime expected)
|
||||
{
|
||||
_owner = owner;
|
||||
_expected = expected;
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue