The obvious solution:
BaseObject baseObject = null;
if ( /* searchResult is a User */ )
{
var user = new User() { /* Set User-specific properties */ };
baseObject = user;
}
else if ( /* searchResult is a Group */ )
{
var group = new Group() { Set /* Group-specific properties */ };
baseObject = group;
}
if (baseObject != null)
{
// Set common properties in baseObject which is a
// reference to the underlying derived type
}
yield return baseObject;
carlsb3rg
2010-07-14 11:00:16