0

C99 標準ライブラリのさまざまな関数ヘッダーに関する情報を表示するアプリケーションを開発しています。ご想像のとおり、これらのヘッダーの一部にはかなりの数の機能が含まれています...メイン画面に配置するよりも多くの機能があります。それを処理するより良い方法は、ヘッダーごとにグループを作成することだと思います(要約ITEMがあり、次に関数ITEMSを含む関数GROUPがあります)、それらは独自のページにあります。

ただし、Microsoft 提供のテンプレートを使用してプログラムでこれを行うのに問題があります。

グループ「complex.h」のコードは次のとおりです。これには、理想的には要約項目と「ComplexConstituents」という名前のグループが含まれます。

var complexGroup = new SampleDataGroup("<complex.h>",
                "<complex.h>",
                "complex arithmetic",
                "Assets/LightGray.png",
                "Group Description: ");
        complexGroup.Items.Add(new SampleDataItem("Group-2-Item-1",
                "Summary",
                "summary of <complex.h>",
                "Assets/DarkGray.png",
                "Item Description: summary of <complex.h>",
                ITEM_CONTENT,
                complexGroup));
        this.AllGroups.Add(complexGroup);
        var complexConstituents = new SampleDataGroup("<complex.h> functions",
                "<complex.h> functions",
                "functions included in the <complex.h> header",
                "Assets/MediumGray.png",
                "Group description: blah");
        this.ComplexConstituents.Add(complexConstituents);

ここで「AllGroups」を補足するために 2 番目のタイプのグループを追加したことに気付いたかもしれません。それは「ComplexConstituents」であり、 の構成関数を含む内部のグループであると想定されています。比較のために「AllGroups」のコンストラクターを使用したコンストラクターを次に示します。

    private ObservableCollection<SampleDataGroup> _allGroups = new ObservableCollection<SampleDataGroup>();
    public ObservableCollection<SampleDataGroup> AllGroups
    {
        get { return this._allGroups; }
    }
    private ObservableCollection<SampleDataGroup> _complexConstituents = new ObservableCollection<SampleDataGroup>();
    public ObservableCollection<SampleDataGroup> ComplexConstituents
    {
        get { return this._complexConstituents; }
    }

これで十分だと思いますが、何らかの理由でそうではありません。この投稿の最後にエラーが表示されます (写真)。これを修正するにはどうすればよいですか?

編集:

以下は、一部の人から要求された GetItem メソッドです。

public static SampleDataItem GetItem(string uniqueId)
    {
        // Simple linear search is acceptable for small data sets
        var matches = _sampleDataSource.AllGroups.SelectMany(group => group.Items).Where((item) => item.UniqueId.Equals(uniqueId));
        if (matches.Count() == 1) return matches.First();
        return null;
    }
4

1 に答える 1

0

GetItemメソッドでは、 ComplexConstituentsをデータソースとして使用するため、変更を加える必要があります。

このように編集します:

var matches = _sampleDataSource.ComplexConstituents.SelectMany(group => group.Items).Where((item) => item.UniqueId.Equals(uniqueId));

 var matches2 = _sampleDataSource.AllGroups.SelectMany(group => group.Items).Where((item) => item.UniqueId.Equals(uniqueId));

        if (matches.Count() == 1) 
            return matches.First();
        else if(matches2.Count() == 1)
            return matches2.First();
        else
           return null;
于 2013-01-09T21:12:55.860 に答える