I have looked at BindingSource class in wi开发者_StackOverflow社区nform and the datasource member type is Object (http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.datasource.aspx).
Wouldn't it be a better design if datasource was of IDataSource Class Interface like it seems in ASP.NET ?
Having a property of type object allows you to set anything as a data source. Then, the BindingSource is responsible of the transformation. It's only a convenience matter.
From the page you link in you question, if you set to the property:
a null reference, the data source will be an empty
IBindingListof objects. Adding an item sets the list to the type of the added item.a non-list type or object of type "T", you'll get an empty
IBindingListof type "T".an array instance, and it will be a
IBindingListcontaining the array elements.an
IEnumerableinstance will be transformed into anIBindingListcontaining theIEnumerableitems.a List instance containing type "T", and the data source will be an
IBindingListinstance containing type "T".
It seems less safe, since it's not strongly typed, but it appears to be pretty handy.
加载中,请稍侯......
精彩评论