Item プロパティ (ICollection)

絶対軸インデックスのコレクションを含む ICollection インターフェイスにより、コレクションから指定された Cell を取得します。Microsoft Visual C# の場合、このプロパティは CellCollection クラスのインデクサとなります。

名前空間:  Microsoft.AnalysisServices.AdomdClient
アセンブリ:  Microsoft.AnalysisServices.AdomdClient (Microsoft.AnalysisServices.AdomdClient.dll)

構文

'宣言
Public ReadOnly Default Property Item ( _
    indexes As ICollection _
) As Cell
    Get
'使用
Dim instance As CellCollection
Dim indexes As ICollection
Dim value As Cell

value = instance(indexes)
public Cell this[
    ICollection indexes
] { get; }
public:
property Cell^ default[ICollection^ indexes] {
    Cell^ get (ICollection^ indexes);
}
member Item : Cell
JScript はインデックス化されたプロパティの使用をサポートしていますが、新規の宣言はサポートしていません。

パラメーター

説明

ICollection は、コレクションによって参照される CellSet で表される各軸から単一のポイントを参照することで作成される組を表します。ICollection 内の各要素のインデックスは、CellSetAxes コレクション内の各軸のインデックスと一致し、各要素の値は、各軸の行の 0 から始まるインデックスを表します。

次の図は、CellSetAxes コレクションを示したものです。Axes コレクションには 3 本の軸が含まれ、0 から 2 までの番号が付いています。各軸から 1 つの組が選択され、単一の Cell を表す組を示します。

3 本の軸に沿った組の積集合を示す図です。

組 4 は Axes.Item(0) から選択され、組 2 は Axes.Item(1) から選択され、組 5 は Axes.Item(2) から選択されます。したがって、ICollection は、3 つの要素を含み、0 から 2 までの番号が付けられ、それぞれに値 4、2、5 が割り当てられていなければなりません。

ICollection が Axes コレクションより多くの要素を含む場合は、例外がスローされます。

ICollection インターフェイスの詳細については、「System.Collections..::..ICollection」を参照してください。

次の例で示すラッパー関数は、CellSet と軸インデックスのリストを受け取り、ICollection を使用して Item プロパティを安全に呼び出します。

Public Function GetCellByArray(_
    ByRef CellSetToUse As CellSet, _
    ByVal ParamArray AxisIndexes() As Int32) As Cell

    ' Trap the various errors that can occur when
    ' retrieving a Cell object reference using an ICollection.
    If CellSetToUse Is Nothing Then
        Throw New System.ArgumentNullException("CellSetToUse")
    ElseIf AxisIndexes Is Nothing Then
        Throw New System.ArgumentNullException("AxisIndexes")
    ElseIf AxisIndexes.Length = 0 Then
        Throw New System.ArgumentNullException("AxisIndexes")
    ElseIf AxisIndexes.Length > CellSetToUse.Axes.Count Then
        Throw New System.ArgumentOutOfRangeException("AxisIndexes")
    Else
        Try
            ' Cast the ParamArray object as an ICollection object, 
            ' just to be safe.
            Dim AxisArrayList As New ICollection(AxisIndexes)

            Return CellSetToUse.CellCollection.Item(AxisArrayList)
        Catch ex As AdomdConnectionException
            ' The connection could not be opened or was disconnected.
            ' This error can occur at any time, if the provider is 
            ' disconnected from the server.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdErrorResponseException
            ' A response is received from a provider which indicates an error.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdUnknownResponseException
            ' A response has been returned from the provider that 
            ' was not understood.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdCacheExpiredException
            ' A cached version of an ADOMD.NET object is no longer valid.
            ' This error is typically raised when reviewing metadata.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdException
            ' Any other error raised by ADOMD.NET.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As Exception
            ' Any other error.
            Debug.WriteLine(ex)
            Throw ex
        End Try
    End If
End Function

次の例で示す関数は、CellSet と軸インデックスのリストを受け取り、CellCollection コレクション内の Cell のインデックスを計算します。

Public Function GetCellIndexFromAxisIndexes(_
    ByRef CellSetToUse As CellSet, _
    ByVal ParamArray AxisIndexes() As Int32) As Int32
    ' Trap the various errors that can occur when
    ' calculating a Cell index using an ICollection.
    If CellSetToUse Is Nothing Then
        Throw New System.ArgumentNullException("CellSetToUse")
    ElseIf AxisIndexes.Length = 0 Then
        Throw New System.ArgumentNullException("AxisIndexes")
    ElseIf AxisIndexes.Length > CellSetToUse.Axes.Count Then
        Throw New System.ArgumentOutOfRangeException("AxisIndexes")
    Else
        Dim currentIndex As Int32 = 0
        Dim currentOrdinal As Int32 = 0
        Dim currentMultiple As Int32 = 1

        Try
            For currentIndex = 0 To AxisIndexes.Length - 1
                currentOrdinal += currentMultiple * AxisIndexes(currentIndex)
                currentMultiple *= CellSetToUse.Axes(currentIndex).Tuples.Count
            Next
        Catch e As System.Exception
            Throw e
        End Try

        Return currentOrdinal
    End If
End Function