ListSourceHelper Class

Definition

在实现由 IListSource 接口定义的成员时,由数据源控件使用。Used by data source controls when implementing the members defined by the IListSource interface. 此类不能被继承。This class cannot be inherited.

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

Examples

下面的代码示例演示了实现IListSource方法的数据源类的设计模式。The following code example demonstrates the design pattern for a data source class that implements the IListSource methods.

#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

Remarks

类是一个实用工具类, 它提供用于通过数据源IListSource控件简化接口的实现。 ListSourceHelperThe ListSourceHelper class is a utility class provided to simplify implementation of the IListSource interface by data source controls. 实现IDataSource接口但不DataSourceControl扩展类的数据源控件可以在其IListSource自身的实现中ListSourceHelper使用该接口所定义的方法的静态方法。Data source controls that implement the IDataSource interface but do not extend the DataSourceControl class can use the static ListSourceHelper methods in their own implementations of the methods defined by the IListSource interface. DataSourceControl类扩展的数据源控件会自动继承这些方法实现。Data source controls that extend from the DataSourceControl class inherit these method implementations automatically.

Methods

ContainsListCollection(IDataSource)

指示指定数据源控件是否包含数据源视图对象的集合。Indicates whether the specified data source control contains a collection of data source view objects.

GetList(IDataSource)

检索数据源对象的 IList 集合。Retrieves an IList collection of data source objects.

Applies to

See also