Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root Enum Pairing not working #138

Closed
nikhilagrawaldotnet opened this issue May 7, 2019 · 5 comments
Closed

Root Enum Pairing not working #138

nikhilagrawaldotnet opened this issue May 7, 2019 · 5 comments
Assignees

Comments

@nikhilagrawaldotnet
Copy link

nikhilagrawaldotnet commented May 7, 2019

I have tried using mapping 2 custom Enums but it always give default enum instead of mapping rules.

Code - ASP.Net Core 2.2
Agile library - AgileObjects.AgileMapper (1.3.0)

public enum MyEnum
{
    Hi,
    Hello
}

public enum MyEnumNew
{
    NwmHello,
    NwmHi
}

In my MappingConfiguration I have done

public class MappingConfiguration : MapperConfiguration
{
    protected override void Configure()
    {          
        Mapper.WhenMapping.PairEnum(MyEnum.Hi).With(MyEnumNew.NwmHi);
        Mapper.WhenMapping.PairEnum(MyEnum.Hello).With(MyEnumNew.NwmHello);            
    }
}

and used it like

var myValue = Mapper.Map(MyEnum.Hi).ToANew<MyEnumNew>();

But it always gives NwmHello

@nikhilagrawaldotnet nikhilagrawaldotnet changed the title Enum Mapping now working Enum Mapping not working May 7, 2019
@SteveWilkes SteveWilkes self-assigned this May 7, 2019
@bslbckr
Copy link

bslbckr commented May 7, 2019

I can confirm this behavior for version 1.4.0, too.

@SteveWilkes
Copy link
Member

Hi!

Thanks for the feedback - I guess it was a lack of imagination on my part, but I never designed enum pairing to work with root enum values - it only works for enum members, like this.

Makes sense that it should work, though - I'll sort it out!

Cheers,

Steve

@SteveWilkes SteveWilkes changed the title Enum Mapping not working Root Enum Pairing not working May 7, 2019
@bslbckr
Copy link

bslbckr commented May 7, 2019

In our use-case the problem occurred when using some fairy complex mappings, involving some factory-methods. Within the factory-mappings we would like to be able to reuse the currently configured enum-mapping.

@SteveWilkes
Copy link
Member

This is supported in the latest code, release to follow. Thanks for the feedback! :)

@SteveWilkes SteveWilkes added the in-preview A feature or bug fix exists in a preview release, and a full release will follow label May 14, 2019
@SteveWilkes
Copy link
Member

This is supported as of v1.5-preview1, which I've just uploaded to NuGet. Thanks again! :)

@SteveWilkes SteveWilkes removed the in-preview A feature or bug fix exists in a preview release, and a full release will follow label Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants