EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
// Check to see if the provider we get is a ReflectTypeDescriptionProvider.
// If so, we can call on it directly rather than creating another
// custom type descriptor
TypeDescriptionProvider p = _node.Provider;
ReflectTypeDescriptionProvider rp = p as ReflectTypeDescriptionProvider;
if (rp != null)
{
// There is no need to filter these events. For extended objects, they
// are accessed through our pipeline code, which always filters before
// returning. So any filter we do here is redundant. Note that we do
// pass a valid filter to a custom descriptor so it can optimize if it wants.
EventDescriptorCollection events = rp.GetExtendedEvents(_instance);
return events;
}
ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
if (desc == null) throw new InvalidOperationException(SR.Format(SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetExtendedTypeDescriptor"));
EventDescriptorCollection evts = desc.GetEvents(attributes);
if (evts == null) throw new InvalidOperationException(SR.Format(SR.TypeDescriptorProviderError, _node.Provider.GetType().FullName, "GetEvents"));
return evts;
}