Last active
August 1, 2018 16:04
-
-
Save af4jm/c1f1da0997f0c27990b3ee0b9646045e to your computer and use it in GitHub Desktop.
make AutoMapper IDataReader conversion work with SmartEnum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyCompany.MyApp.Core.Enums | |
{ | |
using Ardalis.SmartEnum; | |
using AutoMapper; | |
public abstract class SmartEnumTypeConverter<TValue, TEnum> : ITypeConverter<TValue, TEnum> | |
where TEnum : SmartEnum<TEnum, TValue> | |
{ | |
protected SmartEnumTypeConverter() | |
{ | |
} | |
public TEnum Convert(TValue source, TEnum destination, ResolutionContext context) | |
{ | |
return (TEnum)source; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyCompany.MyApp.Core.Enums | |
{ | |
public class TestEnumTypeConverter : SmartEnumTypeConverter<int, TestEnum> | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment