ListSourceHelper Klasa

Definicja

Używane przez kontrolki źródła danych podczas implementowania elementów członkowskich zdefiniowanych przez IListSource interfejs. Klasa ta nie może być dziedziczona.

public ref class ListSourceHelper abstract sealed
public static class ListSourceHelper
type ListSourceHelper = class
Public Class ListSourceHelper
Dziedziczenie
ListSourceHelper

Przykłady

Poniższy przykład kodu przedstawia wzorzec projektowy dla klasy źródła danych, która implementuje IListSource metody.

#region Implementation of IDataSource

public virtual DataSourceView GetView(string viewName) {
    if (null == view) {
        view = new SomeDataSourceView(this);
    }
    return view;
}

public virtual ICollection GetViewNames() {
    ArrayList al = new ArrayList(1);
    al.Add(GetView(String.Empty).Name);
    return al as ICollection;
}

event EventHandler IDataSource.DataSourceChanged {
    add {
        ((IDataSource)this).DataSourceChanged += value;
    }
    remove {
        ((IDataSource)this).DataSourceChanged -= value;
    }
}

#endregion
#region Implementation of IListSource

bool IListSource.ContainsListCollection {
    get {
        return ListSourceHelper.ContainsListCollection(this);
    }
}

IList IListSource.GetList() {
    return ListSourceHelper.GetList(this);
}

#endregion
#Region "Implementation of IDataSource"

Public Overridable Function GetView(viewName As String) As DataSourceView Implements IDataSource.GetView
   If view Is Nothing Then
      view = New SomeDataSourceView(Me)
   End If
   Return view
End Function 'GetView


Public Overridable Function GetViewNames() As ICollection Implements IDataSource.GetViewNames
   Dim al As New ArrayList(1)
   al.Add(GetView(String.Empty).Name)
   Return CType( al, ICollection)
End Function 'GetViewNames

Event DataSourceChanged As EventHandler Implements IDataSource.DataSourceChanged

#End Region

#Region "Implementation of IListSource"

ReadOnly Property ContainsListCollection() As Boolean Implements IListSource.ContainsListCollection
   Get
      Return ListSourceHelper.ContainsListCollection(Me)
   End Get
End Property


Function GetList() As IList Implements IListSource.GetList
   Return ListSourceHelper.GetList(Me)
End Function 'IListSource.GetList

#End Region

Uwagi

Klasa ListSourceHelper jest klasą narzędziową udostępnianą w celu uproszczenia implementacji interfejsu IListSource przez kontrolki źródła danych. Kontrolki źródła danych, które implementują IDataSource interfejs, ale nie rozszerzają DataSourceControl klasy, mogą używać metod statycznych ListSourceHelper we własnych implementacjach metod zdefiniowanych przez IListSource interfejs. Kontrolki źródła danych, które rozszerzają klasę DataSourceControl , dziedziczą te implementacje metod automatycznie.

Metody

ContainsListCollection(IDataSource)

Wskazuje, czy określona kontrolka źródła danych zawiera kolekcję obiektów widoku źródła danych.

GetList(IDataSource)

IList Pobiera kolekcję obiektów źródła danych.

Dotyczy

Zobacz też