using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Utils; namespace Stub { static class EnumsMapper { public static EnumsMapper BiddingsMapper { get; } = new EnumsMapper( Tuple.Create(Model.Languages.Unknown, LibraryDTO.Languages.Unknown), Tuple.Create(Model.Languages.French, LibraryDTO.Languages.French), Tuple.Create(Model.Languages.English, LibraryDTO.Languages.English) ); public static TModel ToModel(this TDTO dto) where TModel : Enum where TDTO : Enum { foreach (var prop in typeof(EnumsMapper).GetProperties()) { if (prop.PropertyType.Equals(typeof(EnumsMapper))) { return (prop.GetValue(null) as EnumsMapper).GetModel(dto); } } return default(TModel); } public static Model.Languages ToModel(this LibraryDTO.Languages dto) => ToModel(dto); public static TDTO ToDTO(this TModel model) where TModel : Enum where TDTO : Enum { foreach (var prop in typeof(EnumsMapper).GetProperties()) { if (prop.PropertyType.Equals(typeof(EnumsMapper))) { return (prop.GetValue(null) as EnumsMapper).GetEntity(model); } } return default(TDTO); } public static LibraryDTO.Languages ToDTO(this Model.Languages model) => ToDTO(model); } }