[Mono-dev] [PATCH] fix for functional incompatibility in HierarchicalDataBoundControl

James Fitzsimons james.fitzsimons at gmail.com
Sun May 18 12:16:20 EDT 2008


Hi all,

The attached patch fixes an in incompatibility between mono and the
Microsoft framework with respect to the HierarchicaDataBoundControl. In my
project I have a class (CategoryHierarchy) that implements
IHierarchicalEnumerable and also have a custom control (CategoryControl)
that extends HierarchicaDataBoundControl. In the Microsoft.Net framework I
can set the datasource of my CategoryControl to be an instance of
CategoryHierarchy and everything works as expected. This throws a null
reference exception in Mono because in the GetData method calls the
GetDataSource method which returns the datasource as a
IHierarchicalDataSource. My CategoryHierarchy doesn't implement
IHierarchicalDataSource hence the null reference exception.

I noticed when inspecting the type of the returned
HierarchicalDataSourceView in visual studio that it was a
ReadOnlyDataSourceView. There is no documentation on this class and no
implementation in Mono so I inferred that it must be a basic default
implementation of HierarchicalDataSourceView that is used in the case where
the datasource implements IHierarchicalEnumerable. I have added a default
implementation of  HierarchicalDataSourceView  (also called
ReadOnlyDataSourceView for conformity) and modified the GetData method of
the HierarchicalDataBoundControl such that if the datasource implements
IHierarchicalEnumerable it returns a new instance of ReadOnlyDataSourceView
instead of null.

I've also added a unit test for this.

Hopefully I've explained that clearly?

Cheers,
James Fitzsimons
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080518/e97b5d73/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HierarchicalDataBoundControl.patch
Type: text/x-diff
Size: 5064 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080518/e97b5d73/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReadOnlyDataSourceView.cs
Type: text/x-csharp
Size: 1683 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080518/e97b5d73/attachment-0001.bin 


More information about the Mono-devel-list mailing list