Właściwość CellCollection.Item (ICollection)
Pobiera określony Cell z kolekcja przez kolekcja ICollection interfejs, który zawiera kolekcja indeksy bezwzględne oś.W Microsoft Visual C#, ta właściwość jest indeksowanie dla CellCollection klasy
Przestrzeń nazw: Microsoft.AnalysisServices.AdomdClient
Zestaw: Microsoft.AnalysisServices.AdomdClient (w Microsoft.AnalysisServices.AdomdClient.dll)
Składnia
'Deklaracja
Public ReadOnly Default Property Item ( _
indexes As ICollection _
) As Cell
Get
'Użycie
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
Język JScript obsługuje używanie indeksowanych właściwości, ale nie obsługuje deklarowania nowych.
Parametry
- indexes
Typ: System.Collections.ICollection
kolekcja ICollection zawiera liczbę elementów mniejsza lub równa Liczba osi CellSet wskazaną przez kolekcja.
Wartość właściwości
Uwagi
kolekcja ICollection reprezentuje spójna kolekcja utworzone przez odwoływanie się do pojedynczego punktu z każdej oś reprezentowane w CellSet wskazaną przez kolekcja.Indeks każdy element w kolekcja ICollection indeksu w poszczególnych oś odpowiada Axes kolekcja CellSet, i wartość każdego elementu reprezentuje indeksu wierszy dla każdej oś.
Poniższy diagram ilustruje Axes kolekcja CellSet.Axes Kolekcja zawiera trzy osie numerowane od 0 do 2.Następnie wybrano jednej spójna kolekcja z każdej z oś do identyfikowania spójna kolekcja reprezentującym pojedynczy Cell.
Diagram przedstawiający przecięcia krotek wzdłuż trzech osi.
4 spójna kolekcja jest wybierany z Axes.Item(0), 2 spójna kolekcja jest wybierany z Axes.Item(1), i wybrano spójna kolekcja 5 z Axes.Item(2).Dlatego kolekcji ICollection powinien zawierać trzy elementy również ponumerowane od 0 do 2 i przypisane wartości 4, 2, i 5, odpowiednio.
Jeśli kolekcja ICollection zawiera więcej elementów niż Axes kolekcja jest wyjątek.
Więcej informacji o kolekcji ICollection interfejs, zobacz System.Collections.ICollection.
Przykłady
Następujące podany przykład pokazuje funkcja otoki, CellSet i bezpiecznie wywołuje listy indeksów oś Item za pomocą właściwość kolekcji ICollection:
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
Poniżej podany przykład pokazuje funkcja, CellSet i listy indeksów oś oblicza Indeks Cell w CellCollection kolekcja.
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
Zobacz także