[英]Issue with Impromptu in C#
I am using Impromptu in C# and I have the following situation.我在 C# 中使用 Impromptu,我有以下情况。
This is my class that I am populating:这是我正在填充的 class:
public class FinalDecisionInformation
{
public int PersonNo { get; set; }
public int OrdNo { get; set; }
public int OrdLineNo { get; set; }
public int OrdStatus { get; set; }
}
This is the definition of the interface IFinalDecisionEvaluate:这是接口 IFinalDecisionEvaluate 的定义:
public interface IFinalDecisionEvaluate
{
List<FinalDecisionInformation> FinalDecisionList { get; set; }
}
My code is currently looking like this:我的代码目前看起来像这样:
List<FinalDecisionInformation> finalDecision = (List<FinalDecisionInformation>)serializer.Deserialize(stringReader);
var finalDecisionSend = Impromptu.ActLike<IFinalDecisionEvaluate>(finalDecision);
This code is throwing the following error:此代码引发以下错误:
((ActLike_IFinalDecisionEvaluate_f627852407d342cb8e77c394c0b2791f)finalDecisionSend).FinalDecisionList = '((ActLike_IFinalDecisionEvaluate_f627852407d342cb8e77c394c0b2791f)finalDecisionSend).FinalDecisionList' threw an exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException'
So essentially, I need to simply map my list object to the interface.所以本质上,我需要简单地将 map 我的列表 object 到接口。 Can anyone please assist with this error?谁能帮助解决这个错误? I cannot figure out where the mismatch is.我无法弄清楚不匹配在哪里。
Thanks!谢谢!
Ah, I think I figured it out.啊,我想我明白了。 I needed to create a proxy object with the field name specified in the interface:我需要使用接口中指定的字段名称创建一个代理 object:
var finalDecisionList = new { FinalDecisionList = finalDecision };
var finalDecisionSend = Impromptu.ActLike<IFinalDecisionEvaluate>(finalDecisionList);
That seems to work.这似乎行得通。 So we learn!所以我们学习!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.