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

RegisterCustom and MapExists #140

Open
nicolasn79 opened this issue May 19, 2017 · 1 comment
Open

RegisterCustom and MapExists #140

nicolasn79 opened this issue May 19, 2017 · 1 comment

Comments

@nicolasn79
Copy link

Mapper.MapExists() method return false for Register made using RegisterCustom<T, TN>(Func<T, TN> mapFunc) method. Is it the normal behaviour ?

See code sample:
using System;
using ExpressMapper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace RegisterCustomIssue
{
enum CHAR
{
A,
B,
C
}

enum NBR
{
ONE,
TWO,
THREE
}

public static class RegisterMapper
{
public static void Register()
{
if (!Mapper.MapExists(typeof(CHAR), typeof(NBR)))
{
Mapper.RegisterCustom<CHAR, NBR>(
src =>
{
switch (src)
{
case CHAR.A: return NBR.ONE;
case CHAR.B: return NBR.TWO;
case CHAR.C: return NBR.THREE;
default: return NBR.ONE;
}
}
);
}
}
}

[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
RegisterMapper.Register();
RegisterMapper.Register();
Assert.IsTrue(true);
}
}
}

@tigrab-dpl
Copy link

Hello,
i am facing the same problem. Ican not detect wether a registartion is done or not. Is there any news? I get following error:
System.InvalidOperationException: Mapping from System.Data.DataTable to System.Collections.Generic.List`1[[DPLDataProvider.Models.Model, DPLDataProvider, Version=0.0.9.0, Culture=neutral, PublicKeyToken=null]] is already registered
bei ExpressMapper.MappingServiceProvider.RegisterCustomT,TN,TMapper in C:\Source\ExpressMapper\Expressmapper.Shared\MappingServiceProvider.cs:Zeile 999.

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