Skip to content

Commit

Permalink
move CsvExportArtikelArtExtension.GetDescription to EnumExtension.Get…
Browse files Browse the repository at this point in the history
…Description
  • Loading branch information
ewu-nma committed Jan 21, 2025
1 parent 01bdff7 commit 9589cba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Gandalan.Client.Contracts.DataServices;

namespace Gandalan.IDAS.WebApi.DTO;
Expand Down Expand Up @@ -77,13 +76,3 @@ public enum ExportFarbArt
Trendfarbe,
Sonderfarbe,
}

public static class CsvExportArtikelArtExtension
{
public static string GetDescription(this Enum value)
{
var field = value.GetType().GetField(value.ToString());
var attribute = field.GetCustomAttribute<DescriptionAttribute>();
return attribute == null ? value.ToString() : attribute.Description;
}
}
15 changes: 15 additions & 0 deletions Gandalan.IDAS.WebApi.Client/Extensions/EnumExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel;
using System.Reflection;

// ReSharper disable once CheckNamespace
namespace System;

public static class EnumExtension
{
public static string GetDescription(this Enum value)
{
var field = value.GetType().GetField(value.ToString());
var attribute = field.GetCustomAttribute<DescriptionAttribute>();
return attribute == null ? value.ToString() : attribute.Description;
}
}

0 comments on commit 9589cba

Please sign in to comment.