diff --git a/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs b/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs index 9f67911..ba69146 100644 --- a/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs +++ b/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; using Telegrator.Filters.Components; using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Abstracts; +using Telegrator.StateKeeping.Components; namespace Telegrator.Attributes.Components { diff --git a/Telegrator/Attributes/StateKeeperAttribute.cs b/Telegrator/Attributes/StateKeeperAttribute.cs index 276dfc9..dcf0e02 100644 --- a/Telegrator/Attributes/StateKeeperAttribute.cs +++ b/Telegrator/Attributes/StateKeeperAttribute.cs @@ -2,7 +2,6 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Attributes.Components; using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Abstracts; using Telegrator.StateKeeping.Components; namespace Telegrator.Attributes diff --git a/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs b/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs index e753beb..eb2d360 100644 --- a/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs +++ b/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs @@ -5,7 +5,6 @@ using Telegrator.Filters.Components; using Telegrator.Handlers.Components; using Telegrator.MadiatorCore; using Telegrator.MadiatorCore.Descriptors; -using Telegrator.StateKeeping.Abstracts; using Telegrator.StateKeeping.Components; namespace Telegrator.Handlers.Building.Components diff --git a/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs b/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs index bfa3b3a..f280f4d 100644 --- a/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs +++ b/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs @@ -1,7 +1,6 @@ using Telegram.Bot.Types; using Telegrator.Annotations.StateKeeping; using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Abstracts; using Telegrator.StateKeeping.Components; namespace Telegrator.Handlers.Building.Components diff --git a/Telegrator/Handlers/Building/Components/StateKeepFilter.cs b/Telegrator/Handlers/Building/Components/StateKeepFilter.cs index 432c5ca..41534e4 100644 --- a/Telegrator/Handlers/Building/Components/StateKeepFilter.cs +++ b/Telegrator/Handlers/Building/Components/StateKeepFilter.cs @@ -2,7 +2,6 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Filters; using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Abstracts; using Telegrator.StateKeeping.Components; namespace Telegrator.Handlers.Building.Components diff --git a/Telegrator/Handlers/Building/TypesExtensions.cs b/Telegrator/Handlers/Building/TypesExtensions.cs index 5e6bb5a..4963eb6 100644 --- a/Telegrator/Handlers/Building/TypesExtensions.cs +++ b/Telegrator/Handlers/Building/TypesExtensions.cs @@ -3,7 +3,6 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Filters.Components; using Telegrator.Handlers.Building.Components; using Telegrator.StateKeeping; -using Telegrator.StateKeeping.Abstracts; using Telegrator.StateKeeping.Components; namespace Telegrator.Handlers.Building diff --git a/Telegrator/Polling/LimitedDictionary.cs b/Telegrator/Polling/LimitedDictionary.cs deleted file mode 100644 index b14c3e2..0000000 --- a/Telegrator/Polling/LimitedDictionary.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections; -using System.Collections.Concurrent; - -namespace Telegrator.Polling -{ - /// - /// Represents a dictionayr with limited number of slots, if trying to overflow, will block calling thread until one of slots will be free - /// - /// - /// - public class LimitedDictionary : IEnumerable>, IDisposable - { - private readonly int? _maximum; - private readonly SemaphoreSlim _semaphore = null!; - private readonly ConcurrentDictionary _dict = []; - - /// - /// Initializes new instance of - /// - /// - public LimitedDictionary(int? maximum) - { - _maximum = maximum; - if (maximum != null) - { - int value = maximum.Value; - _semaphore = new SemaphoreSlim(value, value); - } - } - - /// - /// Tries to add new element to dictioanry. - /// If all slots are occupied, blocks calling thread. - /// - /// - /// - /// - /// - public async Task Add(TKey key, TValue value, CancellationToken cancellationToken) - { - if (_semaphore != null) - await _semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - - return _dict.TryAdd(key, value); - } - - /// - /// Tries to remove element from dictionay. - /// Frees slot on success. - /// - /// - /// - /// - public bool Remove(TKey key, out TValue result) - { - if (_dict.TryRemove(key, out result)) - { - _semaphore?.Release(1); - return true; - } - - return false; - } - - /// - public IEnumerator> GetEnumerator() => _dict.GetEnumerator(); - - /// - IEnumerator IEnumerable.GetEnumerator() => _dict.GetEnumerator(); - - /// - public void Dispose() - { - GC.SuppressFinalize(this); - _semaphore.Dispose(); - } - } -} diff --git a/Telegrator/Polling/LimitedQueue.cs b/Telegrator/Polling/LimitedQueue.cs deleted file mode 100644 index ba940be..0000000 --- a/Telegrator/Polling/LimitedQueue.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections.Concurrent; - -namespace Telegrator.Polling -{ - /* - public class LimitedQueue - { - private readonly int? _maximum; - private readonly ConcurrentQueue _queue = []; - private readonly SemaphoreSlim _semaphore = null!; - - public LimitedQueue(int? maximum) - { - _maximum = maximum; - if (maximum != null) - { - int value = maximum.Value; - _semaphore = new SemaphoreSlim(value, value); - } - } - - public async Task Enqueue(T item, CancellationToken cancellationToken) - { - if (_maximum.HasValue) - await _semaphore.WaitAsync(cancellationToken); - - _queue.Enqueue(item); - } - - public bool Dequeue(out T result) - { - if (_queue.TryDequeue(out result)) - { - if (_maximum.HasValue) - _semaphore?.Release(1); - - return true; - } - - return false; - } - } - */ -} diff --git a/Telegrator/StateKeeping/Abstracts/UpdateBasedStateKeeperBase.cs b/Telegrator/StateKeeping/Abstracts/UpdateBasedStateKeeperBase.cs deleted file mode 100644 index 202c705..0000000 --- a/Telegrator/StateKeeping/Abstracts/UpdateBasedStateKeeperBase.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Telegrator.StateKeeping.Abstracts -{ - /* - public class UpdateBasedStateKeeperBase - { - } - */ -} diff --git a/Telegrator/StateKeeping/Abstracts/ArrayStateKeeper.cs b/Telegrator/StateKeeping/ArrayStateKeeper.cs similarity index 97% rename from Telegrator/StateKeeping/Abstracts/ArrayStateKeeper.cs rename to Telegrator/StateKeeping/ArrayStateKeeper.cs index 13f738b..120cf01 100644 --- a/Telegrator/StateKeeping/Abstracts/ArrayStateKeeper.cs +++ b/Telegrator/StateKeeping/ArrayStateKeeper.cs @@ -1,4 +1,6 @@ -namespace Telegrator.StateKeeping.Abstracts +using Telegrator.StateKeeping.Components; + +namespace Telegrator.StateKeeping { /// /// Abstract base class for state keepers that manage state transitions using an array of predefined states. diff --git a/Telegrator/StateKeeping/Components/IStateKeepingFacility.cs b/Telegrator/StateKeeping/Components/IStateKeepingFacility.cs deleted file mode 100644 index d083609..0000000 --- a/Telegrator/StateKeeping/Components/IStateKeepingFacility.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Telegrator.StateKeeping.Components -{ - /* - public interface IStateKeepingFacility - { - public void SetState(object key, object value); - - public object GetState(object key); - } - */ -} diff --git a/Telegrator/StateKeeping/Abstracts/StateKeeperBase.cs b/Telegrator/StateKeeping/Components/StateKeeperBase.cs similarity index 98% rename from Telegrator/StateKeeping/Abstracts/StateKeeperBase.cs rename to Telegrator/StateKeeping/Components/StateKeeperBase.cs index e94681d..e2e0193 100644 --- a/Telegrator/StateKeeping/Abstracts/StateKeeperBase.cs +++ b/Telegrator/StateKeeping/Components/StateKeeperBase.cs @@ -1,7 +1,6 @@ using Telegram.Bot.Types; -using Telegrator.StateKeeping.Components; -namespace Telegrator.StateKeeping.Abstracts +namespace Telegrator.StateKeeping.Components { /// /// Base class for managing state associated with updates and keys. diff --git a/Telegrator/StateKeeping/EnumStateKeeper.cs b/Telegrator/StateKeeping/EnumStateKeeper.cs index 1163e6e..ba9a8d8 100644 --- a/Telegrator/StateKeeping/EnumStateKeeper.cs +++ b/Telegrator/StateKeeping/EnumStateKeeper.cs @@ -1,6 +1,5 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Abstracts; namespace Telegrator.StateKeeping { diff --git a/Telegrator/StateKeeping/Facilities/JsonStateKeepingFacility.cs b/Telegrator/StateKeeping/Facilities/JsonStateKeepingFacility.cs deleted file mode 100644 index 5fb45a3..0000000 --- a/Telegrator/StateKeeping/Facilities/JsonStateKeepingFacility.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Telegrator.StateKeeping.Facilities -{ - /* - public class JsonStateKeepingFacility : IStateKeepingFacility - { - } - */ -} diff --git a/Telegrator/StateKeeping/NumericStateKeeper.cs b/Telegrator/StateKeeping/NumericStateKeeper.cs index e5e2122..b8ea824 100644 --- a/Telegrator/StateKeeping/NumericStateKeeper.cs +++ b/Telegrator/StateKeeping/NumericStateKeeper.cs @@ -1,6 +1,6 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Abstracts; +using Telegrator.StateKeeping.Components; namespace Telegrator.StateKeeping { diff --git a/Telegrator/StateKeeping/StringStateKeeper.cs b/Telegrator/StateKeeping/StringStateKeeper.cs index a34660c..cbf8f7b 100644 --- a/Telegrator/StateKeeping/StringStateKeeper.cs +++ b/Telegrator/StateKeeping/StringStateKeeper.cs @@ -1,6 +1,6 @@ using Telegrator.Annotations.StateKeeping; using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Abstracts; +using Telegrator.StateKeeping.Components; namespace Telegrator.StateKeeping { diff --git a/Telegrator/TypesExtensions.cs b/Telegrator/TypesExtensions.cs index 06c4fa0..8584f70 100644 --- a/Telegrator/TypesExtensions.cs +++ b/Telegrator/TypesExtensions.cs @@ -11,7 +11,7 @@ using Telegrator.MadiatorCore; using Telegrator.MadiatorCore.Descriptors; using Telegrator.Providers; using Telegrator.StateKeeping; -using Telegrator.StateKeeping.Abstracts; +using Telegrator.StateKeeping.Components; namespace Telegrator {