我有一个列表/元组,其中填充了一些值。我想将这些值保存到脚本组件中的 OBJECT 类型的变量中。我怎样才能做到这一点。到目前为止,我确实尝试过这个但没有成功。
public class ScriptMain : UserComponent
{
private List<SomeValues> SomeList = new List<SomeValues>();
public override void PreExecute()
{
base.PreExecute();
}
public override void PostExecute()
{
base.PostExecute();
//Object type variable in which I am trying to save list
Variables.LatestDateTime = SomeList;
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
var MatchingRow = SomeList.FirstOrDefault(d => d.Id == Row.Id);
if (MatchingRow == null)
{
SomeList.Add(new DateTimeValues
{
ID = Row.ID,
LatestDateTime = Row.DateTime
});
}
else
{
if (MatchingRow.LatestDateTime < Row.DateTime)
{
MatchingRow.LatestDateTime = Row.DateTime;
}
}
}
public class SomeValues
{
public int Id { get; set; }
public DateTime LatestDateTime { get; set; }
}
}