diff --git a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs index 8aa1313..1eb13ec 100644 --- a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs @@ -14,11 +14,16 @@ public class ListGenericObjects : ICollectionGenericObjects private int _maxCount; public int MaxCount => _maxCount; - public int Count => throw new NotImplementedException(); + public int Count => _collection.Count; - public int SetMaxCount { set => throw new NotImplementedException(); } + public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } - public T? Get(int position) + public ListGenericObjects() + { + _collection = new(); + } + + public T Get(int position) { if (position < 0 || position >= _collection.Count || _collection == null || _collection.Count == 0) return null; diff --git a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs index f116585..2694786 100644 --- a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs @@ -20,7 +20,24 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } + /// /// Конструктор @@ -96,7 +113,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects { return null; } - T temp = _collection[position]; + T? temp = _collection[position]; _collection[position] = null; return temp; }