init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
40
Kreta.WebApi/Naplo/Kreta.Naplo.Domain/V3/Logic/UidLogic.cs
Normal file
40
Kreta.WebApi/Naplo/Kreta.Naplo.Domain/V3/Logic/UidLogic.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using Kreta.Naplo.Domain.V3.Interfaces;
|
||||
|
||||
namespace Kreta.Naplo.Domain.V3.Logic
|
||||
{
|
||||
public static class UidLogic
|
||||
{
|
||||
public static T GetUid<T>(string uidRaw, Converter<string[], T> uidConverter) where T : class, IReadonlyUidRaw
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uidRaw))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] compositeKey = uidRaw.Split(Constant.UidInnerDelimiter);
|
||||
|
||||
T uid = uidConverter.Invoke(compositeKey);
|
||||
return uid;
|
||||
}
|
||||
|
||||
public static string[] GetCompositeKeyElements(string uidRaw) => string.IsNullOrWhiteSpace(uidRaw) ? null : uidRaw.Split(Constant.UidInnerDelimiter);
|
||||
|
||||
public static string Concat(params object[] compositeKeyElements)
|
||||
{
|
||||
for (int i = 0; i < compositeKeyElements.Length; i++)
|
||||
{
|
||||
if (compositeKeyElements[i] == null)
|
||||
{
|
||||
compositeKeyElements[i] = Constant.UidNullValue;
|
||||
}
|
||||
else if (string.IsNullOrWhiteSpace(compositeKeyElements[i].ToString()))
|
||||
{
|
||||
compositeKeyElements[i] = Constant.UidNanValue;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join(Constant.UidInnerDelimiter.ToString(), compositeKeyElements);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue