GetSmartPartInfo fails for subtypes

Topics: CAB & Smart Client Software Factory
Mar 25, 2006 at 6:53 PM
originally posted by: luxspes

Hi!
First of all, let me tell yo I think Composite UI Application Block is a great idea,
and a big leap forward architecturally for .NET applications... now lets go back to work:

In SmartPartInfoProvider the code:

public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
{
return items.Find(delegate(ISmartPartInfo info)
{
return info != null && info.GetType() == smartPartInfoType;
});
}

Does not work if in the items there is an object of a type derived from WindowSmartPartInfo (in my case, my custom EnhancedWindowSmartPartInfo)

IMHO the code should be like this:
public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
{
return items.Find(delegate(ISmartPartInfo info)
{
return info != null && smartPartInfoType.IsInstanceOfType(info);
});
}

I think this correction should be part of the standard distribution... how can I contribute code to it? (and IMHO using IsInstanceOfType should be the recommended practice to allow extension using inheritance... don't you think?)


P.D. And I have found other 2 places where "GetType() == " is being used instead of "IsInstanceOfType"
in: WorkItem.RegisterSmartPartInfo and in FindSmartPartInfo.FindSmartPartInfo... and I am wondering...is the limitation intentional... or a bug?