init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Kreta.Core.Enum;
|
||||
using Kreta.Core.Exceptions;
|
||||
using Kreta.Naplo.Domain.V3.Interfaces;
|
||||
|
||||
namespace Kreta.Naplo.Domain.V3.Indexers
|
||||
{
|
||||
public class UidsCollection<T> : IEnumerable<T> where T : class, IReadonlyUidRaw
|
||||
{
|
||||
private readonly List<T> _uids = new List<T>();
|
||||
|
||||
public UidsCollection(string uidsRaw, Converter<string[], T> uidsConverter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uidsRaw))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] uidArray = uidsRaw.Split(Constant.UidDelimiter);
|
||||
|
||||
if (uidArray.Length > 50)
|
||||
{
|
||||
throw new BlException(BlExceptionType.ListaTobbMint50ElemetTartalmaz);
|
||||
}
|
||||
|
||||
_uids = new List<T>(uidArray.Length);
|
||||
|
||||
for (int i = 0; i < uidArray.Length; i++)
|
||||
{
|
||||
_uids.Add(GetUid(uidArray[i]));
|
||||
}
|
||||
|
||||
T GetUid(string uidRaw)
|
||||
{
|
||||
string[] compositeKey = uidRaw.Split(Constant.UidInnerDelimiter);
|
||||
|
||||
T uid = uidsConverter.Invoke(compositeKey);
|
||||
return uid;
|
||||
}
|
||||
}
|
||||
|
||||
public T this[int index] => _uids[index];
|
||||
|
||||
public IEnumerator GetEnumerator() => throw new NotImplementedException();
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => _uids.GetEnumerator();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue