-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7726060
commit 6f4c19f
Showing
62 changed files
with
425 additions
and
5,726 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...pp/NetDaemon.App/Common/Fluent/Context.cs → src/App/NetDaemon.App/Common/Context.cs
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 NetDaemon.Common.Fluent | ||
namespace NetDaemon.Common | ||
{ | ||
/// <summary> | ||
/// Context | ||
|
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,86 +1,86 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
// using System; | ||
// using System.Collections.Concurrent; | ||
// using System.Runtime.CompilerServices; | ||
// using System.Threading.Tasks; | ||
|
||
[assembly: InternalsVisibleTo("NetDaemon.Daemon.Tests")] | ||
// [assembly: InternalsVisibleTo("NetDaemon.Daemon.Tests")] | ||
|
||
namespace NetDaemon.Common | ||
{ | ||
/// <summary> | ||
/// A class that implements the management of delays and cancel them | ||
/// </summary> | ||
public class DelayResult : IDelayResult | ||
{ | ||
private readonly INetDaemonApp _daemonApp; | ||
private readonly TaskCompletionSource<bool> _delayTaskCompletionSource; | ||
private bool _isCanceled; | ||
// namespace NetDaemon.Common | ||
// { | ||
// /// <summary> | ||
// /// A class that implements the management of delays and cancel them | ||
// /// </summary> | ||
// public class DelayResult : IDelayResult | ||
// { | ||
// private readonly INetDaemonApp _daemonApp; | ||
// private readonly TaskCompletionSource<bool> _delayTaskCompletionSource; | ||
// private bool _isCanceled; | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
/// <param name="delayTaskCompletionSource"></param> | ||
/// <param name="daemonApp"></param> | ||
public DelayResult(TaskCompletionSource<bool> delayTaskCompletionSource, INetDaemonApp daemonApp) | ||
{ | ||
_delayTaskCompletionSource = delayTaskCompletionSource; | ||
_daemonApp = daemonApp; | ||
} | ||
// /// <summary> | ||
// /// Constructor | ||
// /// </summary> | ||
// /// <param name="delayTaskCompletionSource"></param> | ||
// /// <param name="daemonApp"></param> | ||
// public DelayResult(TaskCompletionSource<bool> delayTaskCompletionSource, INetDaemonApp daemonApp) | ||
// { | ||
// _delayTaskCompletionSource = delayTaskCompletionSource; | ||
// _daemonApp = daemonApp; | ||
// } | ||
|
||
/// <inheritdoc/> | ||
public Task<bool> Task => _delayTaskCompletionSource.Task; | ||
// /// <inheritdoc/> | ||
// public Task<bool> Task => _delayTaskCompletionSource.Task; | ||
|
||
internal ConcurrentBag<string> StateSubscriptions { get; set; } = new(); | ||
// internal ConcurrentBag<string> StateSubscriptions { get; set; } = new(); | ||
|
||
/// <inheritdoc/> | ||
public void Cancel() | ||
{ | ||
if (_isCanceled) | ||
return; | ||
// /// <inheritdoc/> | ||
// public void Cancel() | ||
// { | ||
// if (_isCanceled) | ||
// return; | ||
|
||
_isCanceled = true; | ||
foreach (var stateSubscription in StateSubscriptions) | ||
{ | ||
//Todo: Handle | ||
_daemonApp.CancelListenState(stateSubscription); | ||
} | ||
StateSubscriptions.Clear(); | ||
// _isCanceled = true; | ||
// foreach (var stateSubscription in StateSubscriptions) | ||
// { | ||
// //Todo: Handle | ||
// _daemonApp.CancelListenState(stateSubscription); | ||
// } | ||
// StateSubscriptions.Clear(); | ||
|
||
// Also cancel all await if this is disposed | ||
_delayTaskCompletionSource.TrySetResult(false); | ||
} | ||
// // Also cancel all await if this is disposed | ||
// _delayTaskCompletionSource.TrySetResult(false); | ||
// } | ||
|
||
#region IDisposable Support | ||
// #region IDisposable Support | ||
|
||
private bool disposedValue; // To detect redundant calls | ||
// private bool disposedValue; // To detect redundant calls | ||
|
||
/// <summary> | ||
/// Disposes the object and cancel delay | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above. | ||
Dispose(true); | ||
// Suppress finalization. | ||
GC.SuppressFinalize(this); | ||
} | ||
// /// <summary> | ||
// /// Disposes the object and cancel delay | ||
// /// </summary> | ||
// public void Dispose() | ||
// { | ||
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above. | ||
// Dispose(true); | ||
// // Suppress finalization. | ||
// GC.SuppressFinalize(this); | ||
// } | ||
|
||
/// <summary> | ||
/// Disposes the object and cancel delay | ||
/// </summary> | ||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!disposedValue) | ||
{ | ||
if (disposing) | ||
{ | ||
// Make sure any subscriptions are canceled | ||
Cancel(); | ||
} | ||
disposedValue = true; | ||
} | ||
} | ||
// /// <summary> | ||
// /// Disposes the object and cancel delay | ||
// /// </summary> | ||
// protected virtual void Dispose(bool disposing) | ||
// { | ||
// if (!disposedValue) | ||
// { | ||
// if (disposing) | ||
// { | ||
// // Make sure any subscriptions are canceled | ||
// Cancel(); | ||
// } | ||
// disposedValue = true; | ||
// } | ||
// } | ||
|
||
#endregion IDisposable Support | ||
} | ||
} | ||
// #endregion IDisposable Support | ||
// } | ||
// } |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.