init
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// Author: Kovács Kornél (DevKornél) Created On: 2019.09.
|
||||
/// </summary>
|
||||
public static class EnumLogic
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
public static IEnumerable<(int Id, string Nev, string Leiras)> GetEnumWithDisplayNameAttribute(Type enumType)
|
||||
{
|
||||
foreach (object item in Enum.GetValues(enumType))
|
||||
{
|
||||
(int Id, string Nev, string Leiras) returnObject = ((int)item, item.ToString(), null);
|
||||
FieldInfo fieldInfo = item.GetType().GetField(returnObject.Nev);
|
||||
|
||||
if (fieldInfo != null)
|
||||
{
|
||||
DisplayAttribute attributes = (DisplayAttribute)fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();
|
||||
|
||||
if (attributes != null)
|
||||
{
|
||||
returnObject.Leiras = attributes.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
yield return returnObject;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDisplayNameAttribute<T>(T enumValue)
|
||||
{
|
||||
string nev = enumValue.ToString();
|
||||
if (string.IsNullOrWhiteSpace(nev))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FieldInfo fieldInfo = typeof(T).GetField(nev);
|
||||
|
||||
if (fieldInfo != null)
|
||||
{
|
||||
DisplayAttribute attributes = (DisplayAttribute)fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault();
|
||||
|
||||
if (attributes != null)
|
||||
{
|
||||
return attributes.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// Author: Réti-Nagy Tamás Created On: 2019.10.
|
||||
/// </summary>
|
||||
public static class OsztalyCsoportLogic
|
||||
{
|
||||
public static bool IsAktivTagsag(DateTime ido, DateTime ervenyessegKezdete, DateTime? ervenyessegVege)
|
||||
=> ido >= ervenyessegKezdete && (ervenyessegVege == null || ido < ervenyessegVege);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Kreta.Ellenorzo.Domain.VN.Interfaces;
|
||||
|
||||
namespace Kreta.Ellenorzo.Domain.VN.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// Author: Kovács Kornél (DevKornél) Created On: 2019.07.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user