refactor: Projektdateien migriert. Cloud-NuGet-Pakete durch lokale NuGet-Projekte ersetzt.
This commit is contained in:
24
HRD.WebApi/Extensions/EnumExtensions.cs
Normal file
24
HRD.WebApi/Extensions/EnumExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace HRD.WebApi.Extensions
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the Description from the DescriptionAttribute.
|
||||
/// </summary>
|
||||
/// <param name="enumValue"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDescription(this Enum enumValue)
|
||||
{
|
||||
return enumValue.GetType()
|
||||
.GetMember(enumValue.ToString())
|
||||
.First()
|
||||
.GetCustomAttribute<DescriptionAttribute>()?
|
||||
.Description ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
HRD.WebApi/Extensions/StringExtensions.cs
Normal file
22
HRD.WebApi/Extensions/StringExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace HRD.WebApi.Extensions
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static bool IsNullOrEmpty(this string s)
|
||||
{
|
||||
return string.IsNullOrEmpty(s);
|
||||
}
|
||||
|
||||
public static bool IsNullOrWhiteSpace(this string s)
|
||||
{
|
||||
return String.IsNullOrWhiteSpace(s);
|
||||
}
|
||||
|
||||
public static bool Contains(this string src, string toCheck, StringComparison comp)
|
||||
{
|
||||
return src.IndexOf(toCheck, comp) >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
HRD.WebApi/Extensions/SystemExtensions.cs
Normal file
45
HRD.WebApi/Extensions/SystemExtensions.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
//using System;
|
||||
//using System.IO;
|
||||
//using System.Runtime.Serialization;
|
||||
//using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
//namespace HRD.WebApi.Extensions
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Reference Article http://www.codeproject.com/KB/tips/SerializedObjectCloner.aspx
|
||||
// /// Provides a method for performing a deep copy of an object.
|
||||
// /// Binary Serialization is used to perform the copy.
|
||||
// /// </summary>
|
||||
// public static class SystemExtensions
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// Perform a deep Copy of the object.
|
||||
// /// </summary>
|
||||
// /// <typeparam name="T">The type of object being copied.</typeparam>
|
||||
// /// <param name="source">The object instance to copy.</param>
|
||||
// /// <returns>The copied object.</returns>
|
||||
// public static T Clone<T>(this T source)
|
||||
// {
|
||||
// if (!typeof(T).IsSerializable)
|
||||
// {
|
||||
// throw new ArgumentException("The type must be serializable.", nameof(source));
|
||||
// }
|
||||
|
||||
// // Don't serialize a null object, simply return the default for that object
|
||||
// if (Object.ReferenceEquals(source, null))
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
|
||||
// IFormatter formatter = new BinaryFormatter();
|
||||
// Stream stream = new MemoryStream();
|
||||
// using (stream)
|
||||
// {
|
||||
// formatter.Serialize(stream, source);
|
||||
// stream.Seek(0, SeekOrigin.Begin);
|
||||
// return (T)formatter.Deserialize(stream);
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user