Invalin Imapper in IvalueResolver(Automapper)

时间:2018-06-06 10:25:38

标签: c# automapper

我有以下情况:

.ForMember(d => d.Persons, opt => opt.ResolveUsing(new PersonResolver()));

我遇到的问题是最后一次映射:

I/Unity: StopVuforia

         (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
D/AR: RenderManager: Could not retrieve a valid GLSurfaceView in view hierarchy, therefore cannot set any render mode
W/MessageQueue: Handler (android.os.Handler) {90dbee5} sending message to a Handler on a dead thread
                java.lang.IllegalStateException: Handler (android.os.Handler) {90dbee5} sending message to a Handler on a dead thread
                    at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
                    at android.os.Handler.enqueueMessage(Handler.java:643)
                    at android.os.Handler.sendMessageAtTime(Handler.java:612)
                    at android.os.Handler.sendMessageDelayed(Handler.java:582)
                    at android.os.Handler.sendMessage(Handler.java:519)
                    at android.os.Message.sendToTarget(Message.java:416)
                    at com.unity3d.player.UnityPlayer$e.a(Unknown Source)
                    at com.unity3d.player.UnityPlayer$e.b(Unknown Source)
                    at com.unity3d.player.UnityPlayer.b(Unknown Source)
                    at com.unity3d.player.UnityPlayer.a(Unknown Source)
                    at com.unity3d.player.UnityPlayer.a(Unknown Source)
                    at com.unity3d.player.UnityPlayer$17.surfaceDestroyed(Unknown Source)
                    at android.view.SurfaceView.updateWindow(SurfaceView.java:588)
                    at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:247)
                    at android.view.View.dispatchDetachedFromWindow(View.java:15567)
                    at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:4914)
                    at android.view.ViewGroup.removeAllViews(ViewGroup.java:4860)
                    at com.unity3d.player.UnityPlayer.quit(Unknown Source)
                    at com.Accenture.Activity.UnityPlayerActivity.onDestroy(UnityPlayerActivity.java:66)
                    at android.app.Activity.performDestroy(Activity.java:6889)
                    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1175)
                    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4231)
                    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4262)
                    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4536)
                    at android.app.ActivityThread.-wrap19(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6165)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
W/MessageQueue: Handler (android.os.Handler) {90dbee5} sending message to a Handler on a dead thread
                java.lang.IllegalStateException: Handler (android.os.Handler) {90dbee5} sending message to a Handler on a dead thread
                    at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
                    at android.os.Handler.enqueueMessage(Handler.java:643)
                    at android.os.Handler.sendMessageAtTime(Handler.java:612)
                    at android.os.Handler.sendMessageDelayed(Handler.java:582)
                    at android.os.Handler.sendMessage(Handler.java:519)
                    at android.os.Message.sendToTarget(Message.java:416)
                    at com.unity3d.player.UnityPlayer$e.b(Unknown Source)
                    at com.unity3d.player.UnityPlayer.b(Unknown Source)
                    at com.unity3d.player.UnityPlayer.a(Unknown Source)
                    at com.unity3d.player.UnityPlayer.a(Unknown Source)
                    at com.unity3d.player.UnityPlayer$17.surfaceDestroyed(Unknown Source)
                    at android.view.SurfaceView.updateWindow(SurfaceView.java:588)
                    at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:247)
                    at android.view.View.dispatchDetachedFromWindow(View.java:15567)
                    at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:4914)
                    at android.view.ViewGroup.removeAllViews(ViewGroup.java:4860)
                    at com.unity3d.player.UnityPlayer.quit(Unknown Source)
                    at com.Accenture.Activity.UnityPlayerActivity.onDestroy(UnityPlayerActivity.java:66)
                    at android.app.Activity.performDestroy(Activity.java:6889)
                    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1175)
                    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4231)
                    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4262)
                    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4536)
                    at android.app.ActivityThread.-wrap19(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6165)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
W/Unity: Timeout while trying detaching primary window.

现在,在我的 PersonResolver 中,我编写了一种特定方法,将来自 SpecialPerson 类的一些属性映射到我的 Person 类,是 d.Persons 属性。所以:我将SpecialPerson映射到Person,因为一些特殊属性不匹配,我需要特定的逻辑。该特定数据的映射本身并不重要。问题是SpecialPerson和Person之间的某些属性仍然匹配,但我不想在 PersonResolver 中逐个手动映射它们。我考虑在PersonResolver中注入IMapper,以便仍然发生从SpecialPerson和Person的自动转换,并且只有映射非mathing属性。不幸的是,这是不可能的。我怎样才能做到这一点?

0 个答案:

没有答案