を使用して、子リスト内の項目のプロパティを設定:私は性質を持っている親と子のアイテムを持っているのFunc <T, object>
:public class Parent
{
public bool IsValid { get; set; }
public Child ChildItem { get; set; }
public List<ChildListItem> ChildList { get; set; }
}
public class ChildItem
{
public bool IsValid { get; set; }
}
public class ChildListItem
{
public bool IsValid { get; set; }
}
私は値を設定する機能の一般的なリストを取り機能を持っています参考のため
public Func<T, object>[] functions { get; set; }
this.functions = FunctionsToArray<Parent>(x => x.IsValid = true,
x.Child.IsValid = true);
:
foreach (Func<T, object> function in functions)
{
function.Invoke(Parent);
}
機能が同様に読み込まれます。私がやりたいのは何
public static Func<T, object>[] FunctionsToArray<T>(params Func<T, object>[] functions)
{
return functions.ToArray();
}
は、子リストの各項目を設定することで、何かのように:
this.functions = FunctionsToArray<Parent>(x => x.IsValid = true,
x.Child.IsValid = true,
x.ChildList.<something>.IsValid = true);
提案/コメント/何をいただければ幸いです。
恐ろしい、ちょうど私が欲しい、そしてはいアクション対Funcより適切です。 –