public static IDesigner CreateDesigner(IComponent component, Type designerBaseType)
{
Type type = null;
IDesigner result = null;
AttributeCollection attributes = TypeDescriptor.GetAttributes(component);
for (int i = 0; i < attributes.Count; i++)
{
DesignerAttribute designerAttribute = attributes[i] as DesignerAttribute;
if (designerAttribute != null)
{
Type type2 = Type.GetType(designerAttribute.DesignerBaseTypeName);
if (type2 != null && type2 == designerBaseType)
{
ISite site = component.Site;
bool flag = false;
if (site != null)
{
ITypeResolutionService typeResolutionService = (ITypeResolutionService)site.GetService(typeof(ITypeResolutionService));
if (typeResolutionService != null)
{
flag = true;
type = typeResolutionService.GetType(designerAttribute.DesignerTypeName);
}
}
if (!flag)
{
type = Type.GetType(designerAttribute.DesignerTypeName);
}
if (type != null)
{
break;
}
}
}
}
if (type != null)
{
result = (IDesigner)SecurityUtils.SecureCreateInstance(type);
}
return result;
}