ListSourceHelper Třída

Definice

Používá se ovládacími prvky zdroje dat při implementaci členů definovaných rozhraním IListSource . Tuto třídu nelze dědit.

public ref class ListSourceHelper abstract sealed
public static class ListSourceHelper
type ListSourceHelper = class
Public Class ListSourceHelper
Dědičnost
ListSourceHelper

Příklady

Následující příklad kódu ukazuje vzor návrhu pro třídu zdroje dat, která 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

Poznámky

Třída ListSourceHelper je obslužná třída, která zjednodušuje implementaci IListSource rozhraní ovládacími prvky zdroje dat. Ovládací prvky zdroje dat, které implementují IDataSource rozhraní, ale nerozšíří DataSourceControl třídu, mohou používat statické ListSourceHelper metody ve svých vlastních implementacích metod definovaných rozhraním IListSource . Ovládací prvky zdroje dat, které přesahují DataSourceControl z třídy, dědí tyto implementace metod automaticky.

Metody

ContainsListCollection(IDataSource)

Určuje, zda zadaný ovládací prvek zdroje dat obsahuje kolekci objektů zobrazení zdroje dat.

GetList(IDataSource)

Načte kolekci IList objektů zdroje dat.

Platí pro

Viz také