public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
object[] components = null;
if (context != null)
{
ArrayList list = new ArrayList();
list.Add(null);
// Try the reference service first.
//
IReferenceService refSvc = (IReferenceService)context.GetService(typeof(IReferenceService));
if (refSvc != null)
{
object[] objs = refSvc.GetReferences(_type);
int count = objs.Length;
for (int i = 0; i < count; i++)
{
if (IsValueAllowed(context, objs[i]))
list.Add(objs[i]);
}
}
else
{
// Now try IContainer.
//
IContainer cont = context.Container;
if (cont != null)
{
ComponentCollection objs = cont.Components;
foreach (IComponent obj in objs)
{
if (obj != null && _type.IsInstanceOfType(obj) &&
IsValueAllowed(context, obj))
{
list.Add(obj);
}
}
}
}
components = list.ToArray();
Array.Sort(components, 0, components.Length, new ReferenceComparer(this));
}
return new StandardValuesCollection(components);
}