Skip to content

Commit 3e9c00e

Browse files
committed
мелкий рефакторинг
1 parent 6e8c9d8 commit 3e9c00e

1 file changed

Lines changed: 7 additions & 36 deletions

File tree

src/OneScript.StandardLibrary/Collections/ValueList/ValueListImpl.cs

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@ public ValueListImpl()
3737

3838
public override IValue GetIndexedValue(IValue index)
3939
{
40-
if (index.SystemType == BasicTypes.Number)
41-
{
42-
return GetValue(index);
43-
}
44-
else
45-
{
46-
return base.GetIndexedValue(index);
47-
}
40+
return index is BslNumericValue ? GetValue(index) : base.GetIndexedValue(index);
4841
}
4942

5043
public override void SetIndexedValue(IValue index, IValue val)
@@ -62,7 +55,6 @@ public override void SetIndexedValue(IValue index, IValue val)
6255
[ContextProperty("ТипЗначения", "ValueType")]
6356
public TypeDescription ListValueType { get; set; } = new();
6457

65-
6658
ValueListImpl _availableValues;
6759

6860
/// <summary>
@@ -178,10 +170,7 @@ private ValueListItem CreateNewListItem(IValue value, string presentation, bool
178170
/// </summary>
179171
/// <returns>Массив</returns>
180172
[ContextMethod("ВыгрузитьЗначения", "UnloadValues")]
181-
public ArrayImpl UnloadValues()
182-
{
183-
return new ArrayImpl(_items.Select(x=>x.Value));
184-
}
173+
public ArrayImpl UnloadValues() => new ArrayImpl(_items.Select(x => x.Value));
185174

186175
/// <summary>
187176
/// Загружает значения из массива
@@ -198,10 +187,7 @@ public void LoadValues(ArrayImpl source)
198187
/// Удаляет все элементы из списка.
199188
/// </summary>
200189
[ContextMethod("Очистить", "Clear")]
201-
public void Clear()
202-
{
203-
_items.Clear();
204-
}
190+
public void Clear() => _items.Clear();
205191

206192
/// <summary>
207193
/// Устанавливает значение пометки у всех элементов списка значений
@@ -222,10 +208,7 @@ public void FillChecks(bool check)
222208
/// <param name="item">ЭлементСпискаЗначений - Элемент списка значений, для которого необходимо определить индекс</param>
223209
/// <returns>Число - Индекс в списке, если не найдено возвращает -1</returns>
224210
[ContextMethod("Индекс", "IndexOf")]
225-
public int IndexOf(ValueListItem item)
226-
{
227-
return _items.IndexOf(item);
228-
}
211+
public int IndexOf(ValueListItem item) => _items.IndexOf(item);
229212

230213
/// <summary>
231214
/// Осуществляет поиск значения в списке
@@ -282,7 +265,6 @@ private int IndexByValue(BslValue item)
282265
public void Move(BslValue item, int offset)
283266
{
284267
int index_source = IndexByValue(item);
285-
286268
int index_dest = index_source + offset;
287269

288270
if (index_dest < 0 || index_dest >= _items.Count)
@@ -370,25 +352,14 @@ public void SortByPresentation(SortDirectionEnum? direction = null)
370352
/// Число - Индекс удаляемого элемента
371353
/// </param>
372354
[ContextMethod("Удалить", "Delete")]
373-
public void Delete(BslValue item)
374-
{
375-
int indexSource = IndexByValue(item);
376-
377-
_items.RemoveAt(indexSource);
378-
}
355+
public void Delete(BslValue item) => _items.RemoveAt(IndexByValue(item));
379356

380357
#region Collection Context
381358

382359
[ContextMethod("Количество", "Count")]
383-
public override int Count()
384-
{
385-
return _items.Count;
386-
}
360+
public override int Count() => _items.Count;
387361

388-
public override IEnumerator<ValueListItem> GetEnumerator()
389-
{
390-
return _items.GetEnumerator();
391-
}
362+
public override IEnumerator<ValueListItem> GetEnumerator() => _items.GetEnumerator();
392363

393364
#endregion
394365

0 commit comments

Comments
 (0)