私は単一のリストまたは要素を作成する関数を作成しようとしています。LINQ複数のリストを一覧表示します。単一のリストを返す
この要素のリストは、リストの動的リストに含まれる値に基づいてソロを決定します。 リストAたとえば
は保持一覧B.及びリストBを保持しているオブジェクトは、彼らが特別な値を保持している可能性があるリストA、B又はC内のリストC
を保持しているオブジェクトを保持しています。
すべてのリストを検索し、特別な値を保持する値だけを返す関数を作成する必要があります。
私は再帰関数を調べてみましたが、私は近いと思います。
public ObservableCollection<ListViewItem> RecursiveActionBuilder(List<IMetaData> pList)
{
if (pList == null)
return null;
List<ActionObject> actions = new List<ActionObject>();
for (int x = 0; x < pList.Count; x++)
{
ActionObject child = RecursiveActionBuilder(pList[x]);
if (child == null)
continue;
else
actions.Add(child);
}
ObservableCollection<ListViewItem> items = new ObservableCollection<Models.Items.ListViewItem>();
for (int x = 0; x < actions.Count; x++)
items.Add(new ListViewItem()
{
Values = new ListViewValue[]
{
new ListViewValue() { Value = actions[x].Command },
new ListViewValue() { Value = actions[x].Target },
new ListViewValue() { Value = actions[x].Value },
new ListViewValue() { Value = actions[x].Comment }
}
});
return items;
}
public ActionObject RecursiveActionBuilder(IMetaData pObj)
{
if (pObj == null)
return null;
if (pObj.Children == null)
{
if (pObj.Tag == Enums.TestType.Action)
return pObj as ActionObject;
else
return null;
}
ActionObject action = new ActionObject();
for (int x = 0; x < pObj.Children.Count; x++)
{
ActionObject child = RecursiveActionBuilder(pObj.Children[x]);
if (child == null)
continue;
else return child;
}
return null;
}
しかし、すべての 'アクション'を取得しているわけではありません。
思考?質問が暗示するように、この方法
public ActionObject RecursiveActionBuilder(IMetaData pObj)
ではなく、複数のオブジェクトで、単一のオブジェクトを返すので
おかげでイワン、申し訳ありませんただあなたに戻ってきます。私は数時間を与えて、私はあなたの答えをできるだけ早く確認することができます! –
問題ない仲間、私は急いでいません:) –
これは素晴らしいです!アイワンありがとう! –