//TODO: this method is public so that the toolbox service can special-case subclasses of this //to unify them into a single type-walk in a single remote process /// <param name="type">The <see cref="Type"/> of the item for which a node should be created.</param> /// <param name="attribute">The <see cref="ToolboxItemAttribute"/> that was applied to the type.</param> /// <param name="attributeCategory"> The node's category as detected from the <see cref="CategoryAttribute"/>. /// If it's null or empty, the method will need to infer a value.</param> /// <param name="assemblyPath"> If the assembly is a system package, this value will be null. Else, the method will /// need to record the full path in the node.</param> public abstract ItemToolboxNode GetNode( Type type, ToolboxItemAttribute attribute, string attributeCategory, string assemblyPath, MonoDevelop.Core.ClrVersion referencedRuntime );
private static ToolboxItem CreateToolboxItem(Type type, AssemblyName name) { ToolboxItemAttribute attribute1 = (ToolboxItemAttribute) TypeDescriptor.GetAttributes(type)[typeof(ToolboxItemAttribute)]; ToolboxItem item1 = null; if (!attribute1.IsDefaultAttribute()) { Type type1 = attribute1.ToolboxItemType; if (type1 != null) { item1 = CreateToolboxItemInstance(type1, type); if (item1 != null) { if (name != null) { item1.AssemblyName = name; } } } } if (((item1 == null) && (attribute1 != null)) && !attribute1.Equals(ToolboxItemAttribute.None)) { item1 = new ToolboxItem(type); if (name != null) { item1.AssemblyName = name; } } return(item1); }
private static void EnsureDefaultChildHierarchy(IDesignerHost designerHost) { //When we are adding the root activity we need to make sure that all the child activities which are required by the parent //activity are looked up in the toolboxitem and added appropriately //If the composite activity already has a some child activities but not all then it //means that user has changed the InitializeComponent and hence we do nothing //This is the simple check to get the designer working in case of selecting composite //root activities CompositeActivity rootActivity = designerHost.RootComponent as CompositeActivity; if (rootActivity != null && rootActivity.Activities.Count == 0) { object[] attribs = rootActivity.GetType().GetCustomAttributes(typeof(ToolboxItemAttribute), false); ToolboxItemAttribute toolboxItemAttrib = (attribs != null && attribs.GetLength(0) > 0) ? attribs[0] as ToolboxItemAttribute : null; if (toolboxItemAttrib != null && toolboxItemAttrib.ToolboxItemType != null) { ToolboxItem item = Activator.CreateInstance(toolboxItemAttrib.ToolboxItemType, new object[] { rootActivity.GetType() }) as ToolboxItem; IComponent[] components = item.CreateComponents(); //I am assuming here that there will be always one top level component created. //If there are multiple then there is a bigger problem as we dont know how //to use those CompositeActivity compositeActivity = null; foreach (IComponent component in components) { if (component.GetType() == rootActivity.GetType()) { compositeActivity = component as CompositeActivity; break; } } //Add the children if (compositeActivity != null && compositeActivity.Activities.Count > 0) { IIdentifierCreationService identifierCreationService = designerHost.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService; if (identifierCreationService != null) { //We do not go thru the composite designer here as composite activity //might have simple designer Activity[] activities = compositeActivity.Activities.ToArray(); compositeActivity.Activities.Clear(); identifierCreationService.EnsureUniqueIdentifiers(rootActivity, activities); // Work around : Don't called AddRange because it doesn't send the ListChange notifications // to the activity collection. Use multiple Add calls instaead foreach (Activity newActivity in activities) { rootActivity.Activities.Add(newActivity); } foreach (Activity childActivity in activities) { WorkflowDesignerLoader.AddActivityToDesigner(designerHost, childActivity); } } } } } }
public static string GetToolboxDisplayName(Type activityType) { if (activityType == null) { throw new ArgumentNullException("activityType"); } string name = activityType.Name; object[] customAttributes = activityType.GetCustomAttributes(typeof(ToolboxItemAttribute), true); if ((customAttributes != null) && (customAttributes.Length > 0)) { ToolboxItemAttribute attribute = customAttributes[0] as ToolboxItemAttribute; if ((attribute != null) && (attribute.ToolboxItemType != null)) { try { ToolboxItem item = Activator.CreateInstance(attribute.ToolboxItemType, new object[] { activityType }) as ToolboxItem; if (item != null) { name = item.DisplayName; } } catch { } } } if ((((activityType.Assembly != null) && (activityType.Assembly.FullName != null)) && (activityType.Assembly.FullName.Equals("System.Workflow.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", StringComparison.OrdinalIgnoreCase) || activityType.Assembly.FullName.Equals(Assembly.GetExecutingAssembly().FullName, StringComparison.OrdinalIgnoreCase))) && (name.EndsWith("Activity", StringComparison.Ordinal) && !name.Equals("Activity", StringComparison.Ordinal))) { name = name.Substring(0, name.Length - "Activity".Length); } return(name); }
/// <param name="obj">The object to compare.</param> public override bool Equals(object o) { ToolboxItemAttribute toolboxItemAttribute = o as ToolboxItemAttribute; if (toolboxItemAttribute == null) { return(false); } return(toolboxItemAttribute.ToolboxItemTypeName == ToolboxItemTypeName); }
//Gets the toolbox item associated with a component type internal static ToolboxItem GetToolboxItem(Type toolType) { if (toolType == null) { throw new ArgumentNullException("toolType"); } ToolboxItem item = null; if ((toolType.IsPublic || toolType.IsNestedPublic) && typeof(IComponent).IsAssignableFrom(toolType) && !toolType.IsAbstract) { ToolboxItemAttribute toolboxItemAttribute = (ToolboxItemAttribute)TypeDescriptor.GetAttributes(toolType)[typeof(ToolboxItemAttribute)]; if (toolboxItemAttribute != null && !toolboxItemAttribute.IsDefaultAttribute()) { Type itemType = toolboxItemAttribute.ToolboxItemType; if (itemType != null) { // First, try to find a constructor with Type as a parameter. If that // fails, try the default constructor. ConstructorInfo ctor = itemType.GetConstructor(new Type[] { typeof(Type) }); if (ctor != null) { item = (ToolboxItem)ctor.Invoke(new object[] { toolType }); } else { ctor = itemType.GetConstructor(new Type[0]); if (ctor != null) { item = (ToolboxItem)ctor.Invoke(new object[0]); item.Initialize(toolType); } } } } else if (!toolboxItemAttribute.Equals(ToolboxItemAttribute.None)) { item = new ToolboxItem(toolType); } } else if (typeof(ToolboxItem).IsAssignableFrom(toolType)) { // if the type *is* a toolboxitem, just create it.. // try { item = (ToolboxItem)Activator.CreateInstance(toolType, true); } catch { } } return(item); }
public void NonDefaultType() { ToolboxItemAttribute attr = new ToolboxItemAttribute(false); Assert.AreEqual(string.Empty, attr.ToolboxItemTypeName, "#1"); Assert.IsNull(attr.ToolboxItemType, "#2"); Assert.AreEqual(false, attr.IsDefaultAttribute(), "#3"); Assert.AreEqual(string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4"); Assert.IsNull(ToolboxItemAttribute.None.ToolboxItemType, "#5"); Assert.AreEqual(false, ToolboxItemAttribute.None.IsDefaultAttribute(), "#6"); }
// Determine if two attribute values are equal. public override bool Equals(Object obj) { ToolboxItemAttribute other = (obj as ToolboxItemAttribute); if (other != null) { return(ToolboxItemTypeName == other.ToolboxItemTypeName); } else { return(false); } }
private bool IsValidToolType(Type type) { ToolboxItemAttribute toolboxAttribute = TypeDescriptor.GetAttributes(type)[typeof(ToolboxItemAttribute)] as ToolboxItemAttribute; if (toolboxAttribute.ToolboxItemTypeName != ToolboxItemAttribute.None.ToolboxItemTypeName && !type.IsAbstract && !type.IsInterface && ((type.Attributes & TypeAttributes.Public) == TypeAttributes.Public) && ((type.Attributes & TypeAttributes.NestedFamily) != TypeAttributes.NestedFamily) && ((type.Attributes & TypeAttributes.NestedFamORAssem) != TypeAttributes.NestedFamORAssem) && typeof(System.Windows.Forms.Control).IsAssignableFrom(type)) { return(true); } return(false); }
public void DefaultType() { ToolboxItemAttribute attr = new ToolboxItemAttribute(true); Type toolboxItemType = typeof(global::System.Drawing.Design.ToolboxItem); Assert.AreEqual(toolboxItemType.AssemblyQualifiedName, attr.ToolboxItemTypeName, "#1"); Assert.AreEqual(toolboxItemType, attr.ToolboxItemType, "#2"); Assert.AreEqual(true, attr.IsDefaultAttribute(), "#3"); Assert.AreEqual(attr.ToolboxItemTypeName.GetHashCode(), attr.GetHashCode(), "#4"); Assert.AreEqual(toolboxItemType.AssemblyQualifiedName, ToolboxItemAttribute.Default.ToolboxItemTypeName, "#5"); Assert.AreEqual(toolboxItemType, ToolboxItemAttribute.Default.ToolboxItemType, "#2"); Assert.AreEqual(true, ToolboxItemAttribute.Default.IsDefaultAttribute(), "#3"); Assert.AreEqual(ToolboxItemAttribute.Default.ToolboxItemTypeName.GetHashCode(), attr.GetHashCode(), "#4"); }
/// <summary> /// Create a ToolboxItem for the specified activity type /// </summary> /// <param name="activityType"></param> /// <returns></returns> private ToolboxItem CreateItemForActivityType(Type activityType) { ToolboxItem result = null; //does the activity type include the ToolboxItemAttribute ToolboxItemAttribute toolboxAttribute = null; foreach (Attribute attribute in activityType.GetCustomAttributes( typeof(ToolboxItemAttribute), true)) { if (attribute is ToolboxItemAttribute) { toolboxAttribute = (ToolboxItemAttribute)attribute; break; } } if (toolboxAttribute != null) { if (toolboxAttribute.ToolboxItemType != null) { //construct the ToolboxItemType specified //by the attribute. ConstructorInfo constructor = toolboxAttribute.ToolboxItemType.GetConstructor( new Type[] { typeof(Type) }); if (constructor != null) { result = constructor.Invoke( new Object[] { activityType }) as ToolboxItem; } } } else { //no attribute found result = new ToolboxItem(activityType); } return(result); }
public static string GetToolboxDisplayName(Type activityType) { if (activityType == null) { throw new ArgumentNullException("activityType"); } string displayName = activityType.Name; object[] toolboxItemAttributes = activityType.GetCustomAttributes(typeof(ToolboxItemAttribute), true); if (toolboxItemAttributes != null && toolboxItemAttributes.Length > 0) { ToolboxItemAttribute toolboxItemAttrib = toolboxItemAttributes[0] as ToolboxItemAttribute; if (toolboxItemAttrib != null && toolboxItemAttrib.ToolboxItemType != null) { try { ToolboxItem item = Activator.CreateInstance(toolboxItemAttrib.ToolboxItemType, new object[] { activityType }) as ToolboxItem; if (item != null) { displayName = item.DisplayName; } } catch { } } } if (activityType.Assembly != null && activityType.Assembly.FullName != null) { if ((activityType.Assembly.FullName.Equals(AssemblyRef.ActivitiesAssemblyRef, StringComparison.OrdinalIgnoreCase) || activityType.Assembly.FullName.Equals(Assembly.GetExecutingAssembly().FullName, StringComparison.OrdinalIgnoreCase)) && displayName.EndsWith(ActivitySuffix, StringComparison.Ordinal) && !displayName.Equals(ActivitySuffix, StringComparison.Ordinal)) { displayName = displayName.Substring(0, displayName.Length - ActivitySuffix.Length); } } return(displayName); }
public static ToolboxItem GetToolboxItem(System.Type toolType, bool nonPublic) { ToolboxItem item = null; if (toolType == null) { throw new ArgumentNullException("toolType"); } if (((nonPublic || toolType.IsPublic) || toolType.IsNestedPublic) && (typeof(IComponent).IsAssignableFrom(toolType) && !toolType.IsAbstract)) { ToolboxItemAttribute attribute = (ToolboxItemAttribute)TypeDescriptor.GetAttributes(toolType)[typeof(ToolboxItemAttribute)]; if (!attribute.IsDefaultAttribute()) { System.Type toolboxItemType = attribute.ToolboxItemType; if (toolboxItemType != null) { ConstructorInfo constructor = toolboxItemType.GetConstructor(new System.Type[] { typeof(System.Type) }); if ((constructor != null) && (toolType != null)) { return((ToolboxItem)constructor.Invoke(new object[] { toolType })); } constructor = toolboxItemType.GetConstructor(new System.Type[0]); if (constructor != null) { item = (ToolboxItem)constructor.Invoke(new object[0]); item.Initialize(toolType); } } return(item); } if (!attribute.Equals(ToolboxItemAttribute.None) && !toolType.ContainsGenericParameters) { item = new ToolboxItem(toolType); } return(item); } if (typeof(ToolboxItem).IsAssignableFrom(toolType)) { item = (ToolboxItem)Activator.CreateInstance(toolType, true); } return(item); }
private static void EnsureDefaultChildHierarchy(IDesignerHost designerHost) { CompositeActivity rootComponent = designerHost.RootComponent as CompositeActivity; if ((rootComponent != null) && (rootComponent.Activities.Count == 0)) { object[] customAttributes = rootComponent.GetType().GetCustomAttributes(typeof(ToolboxItemAttribute), false); ToolboxItemAttribute attribute = ((customAttributes != null) && (customAttributes.GetLength(0) > 0)) ? (customAttributes[0] as ToolboxItemAttribute) : null; if ((attribute != null) && (attribute.ToolboxItemType != null)) { IComponent[] componentArray = (Activator.CreateInstance(attribute.ToolboxItemType, new object[] { rootComponent.GetType() }) as ToolboxItem).CreateComponents(); CompositeActivity activity2 = null; foreach (IComponent component in componentArray) { if (component.GetType() == rootComponent.GetType()) { activity2 = component as CompositeActivity; break; } } if ((activity2 != null) && (activity2.Activities.Count > 0)) { IIdentifierCreationService service = designerHost.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService; if (service != null) { Activity[] childActivities = activity2.Activities.ToArray(); activity2.Activities.Clear(); service.EnsureUniqueIdentifiers(rootComponent, childActivities); foreach (Activity activity3 in childActivities) { rootComponent.Activities.Add(activity3); } foreach (Activity activity4 in childActivities) { WorkflowDesignerLoader.AddActivityToDesigner(designerHost, activity4); } } } } } }
public void InvalidItemTypeName() { ToolboxItemAttribute attr = new ToolboxItemAttribute("typedoesnotexist"); // this next statement should fail Type type = attr.ToolboxItemType; }
// If the type represents a toolbox item, return an instance of the type; // otherwise, return null. private ToolboxItem CreateToolboxItem(Type possibleItem) { // A toolbox item must implement IComponent and must not be abstract. if (!typeof(IComponent).IsAssignableFrom(possibleItem) || possibleItem.IsAbstract) { return(null); } // A toolbox item must have a constructor that takes a parameter of // type Type or a constructor that takes no parameters. if (null == possibleItem.GetConstructor(new Type[] { typeof(Type) }) && null == possibleItem.GetConstructor(new Type[0])) { return(null); } ToolboxItem item = null; // Check the custom attributes of the candidate type and attempt to // create an instance of the toolbox item type. AttributeCollection attribs = TypeDescriptor.GetAttributes(possibleItem); ToolboxItemAttribute tba = attribs[typeof(ToolboxItemAttribute)] as ToolboxItemAttribute; if (tba != null && !tba.Equals(ToolboxItemAttribute.None)) { if (!tba.IsDefaultAttribute()) { // This type represents a custom toolbox item implementation. Type itemType = tba.ToolboxItemType; ConstructorInfo ctor = itemType.GetConstructor(new Type[] { typeof(Type) }); if (ctor != null && itemType != null) { item = (ToolboxItem)ctor.Invoke(new object[] { possibleItem }); } else { ctor = itemType.GetConstructor(new Type[0]); if (ctor != null) { item = (ToolboxItem)ctor.Invoke(new object[0]); item.Initialize(possibleItem); } } } else { // This type represents a default toolbox item. item = new ToolboxItem(possibleItem); } } if (item == null) { throw new ApplicationException("Unable to create a ToolboxItem " + "object from " + possibleItem.FullName + "."); } // Update the display name of the toolbox item and add the item to // the list. DisplayNameAttribute displayName = attribs[typeof(DisplayNameAttribute)] as DisplayNameAttribute; if (displayName != null && !displayName.IsDefaultAttribute()) { item.DisplayName = displayName.DisplayName; } return(item); }
public override ItemToolboxNode GetNode(Type t, ToolboxItemAttribute tba, string attributeCategory, string fullPath, MonoDevelop.Core.ClrVersion referencedRuntime) { if (referencedRuntime != MonoDevelop.Core.ClrVersion.Net_1_1 && referencedRuntime != MonoDevelop.Core.ClrVersion.Net_2_0) { return(null); } bool reflectedRuntime1; if (typeof(System.Web.UI.Control).IsAssignableFrom(t)) { reflectedRuntime1 = false; } else if (CanRuntime1 && SWUControl1.IsAssignableFrom(t)) { reflectedRuntime1 = true; } else { return(null); } Type toolboxItemType = (tba.ToolboxItemType == null) ? typeof(ToolboxItem) : tba.ToolboxItemType; //FIXME: fix WebControlToolboxItem so that this isn't necessary //right now it's totally broken in mono if (typeof(System.Web.UI.Design.WebControlToolboxItem).IsAssignableFrom(toolboxItemType)) { toolboxItemType = typeof(ToolboxItem); } //Create the ToolboxItem. The ToolboxItemToolboxNode will destroy it, but need to //be able to extract data from it first. ToolboxItem item = (ToolboxItem)Activator.CreateInstance(toolboxItemType, new object[] { t }); AspNetToolboxNode node = new AspNetToolboxNode(item); //get the default markup for the tag string webText = reflectedRuntime1? GetWebText1(t) : GetWebText(t); if (!string.IsNullOrEmpty(webText)) { node.Text = webText; } if (!string.IsNullOrEmpty(attributeCategory)) { node.Category = attributeCategory; } else if (reflectedRuntime1) { node.Category = GuessCategory1(t); } else { node.Category = GuessCategory(t); } if (!string.IsNullOrEmpty(fullPath)) { node.Type.AssemblyLocation = fullPath; } //prevent system.web 1.1 from being shown for 2.0 runtime if (CanRuntime1 && webAssem1.FullName == t.Assembly.FullName) { node.ItemFilters.Add(new ToolboxItemFilterAttribute("ClrVersion.Net_2_0", ToolboxItemFilterType.Prevent)); } //set filters fom supported runtimes if (referencedRuntime == MonoDevelop.Core.ClrVersion.Net_1_1) { node.ItemFilters.Add(new ToolboxItemFilterAttribute("ClrVersion.Net_1_1", ToolboxItemFilterType.Require)); } else if (referencedRuntime == MonoDevelop.Core.ClrVersion.Net_2_0) { node.ItemFilters.Add(new ToolboxItemFilterAttribute("ClrVersion.Net_2_0", ToolboxItemFilterType.Require)); } return(node); }
public static ToolboxItem GetToolboxItem(Type toolType, bool nonPublic = false) { if (toolType == null) { throw new ArgumentNullException("toolType"); } ToolboxItem toolboxItem = null; if ((nonPublic || toolType.IsPublic || toolType.IsNestedPublic) && typeof(IComponent).IsAssignableFrom(toolType) && !toolType.IsAbstract) { AttributeCollection attributeCollection = TypeDescriptor.GetAttributes(toolType); ToolboxItemAttribute toolboxItemAttribute = (ToolboxItemAttribute)attributeCollection[typeof(ToolboxItemAttribute)]; if (!toolboxItemAttribute.IsDefaultAttribute()) { Type toolboxItemType = toolboxItemAttribute.ToolboxItemType; if (toolboxItemType != (Type)null) { ConstructorInfo constructor = toolboxItemType.GetConstructor(new Type[1] { typeof(Type) }); if (constructor != (ConstructorInfo)null && toolType != (Type)null) { toolboxItem = (ToolboxItem)constructor.Invoke(new object[1] { toolType }); } else { constructor = toolboxItemType.GetConstructor(new Type[0]); if (constructor != (ConstructorInfo)null) { toolboxItem = (ToolboxItem)constructor.Invoke(new object[0]); toolboxItem.Initialize(toolType); } } } } else if (!toolboxItemAttribute.Equals(ToolboxItemAttribute.None) && !toolType.ContainsGenericParameters) { toolboxItem = new ToolboxItem(toolType); } if (toolboxItem != null) { toolboxItem.Properties.Add("GroupName", toolType.GetCustomAttributesData() .FirstOrDefault(data => data.AttributeType.FullName == "DevExpress.Utils.ToolboxTabNameAttribute")?.ConstructorArguments[0].Value ?? "Devexpress"); } goto IL_0137; } if (typeof(ToolboxItem).IsAssignableFrom(toolType)) { toolboxItem = (ToolboxItem)Activator.CreateInstance(toolType, true); goto IL_0137; } IL_0137: return(toolboxItem); }
//temporary method until we get a UI and some form of persistence) public void PopulateFromAssembly(Assembly assembly) { Type[] types = assembly.GetTypes(); foreach (Type t in types) { if (t.IsAbstract || t.IsNotPublic) { continue; } if (t.GetConstructor(new Type[] {}) == null) { continue; } AttributeCollection atts = TypeDescriptor.GetAttributes(t); bool containsAtt = false; foreach (Attribute a in atts) { if (a.GetType() == typeof(ToolboxItemAttribute)) { containsAtt = true; } } if (!containsAtt) { continue; } ToolboxItemAttribute tba = (ToolboxItemAttribute)atts[typeof(ToolboxItemAttribute)]; if (tba.Equals(ToolboxItemAttribute.None)) { continue; } //FIXME: fix WebControlToolboxItem Type toolboxItemType = typeof(ToolboxItem); //(tba.ToolboxItemType == null) ? typeof (ToolboxItem) : tba.ToolboxItemType; string category = "General"; if (t.IsSubclassOf(typeof(System.Web.UI.WebControls.BaseValidator))) { category = "Validation"; } else if (t.Namespace == "System.Web.UI.HtmlControls" && t.IsSubclassOf(typeof(System.Web.UI.HtmlControls.HtmlControl))) { category = "Html Elements"; } else if (t.IsSubclassOf(typeof(System.Web.UI.WebControls.BaseDataList))) { category = "Data Controls"; } else if (t.IsSubclassOf(typeof(System.Web.UI.WebControls.WebControl))) { category = "Web Controls"; } AddToolboxItem((ToolboxItem)Activator.CreateInstance(toolboxItemType, new object[] { t }), category); } OnToolboxChanged(); }
IList <ItemToolboxNode> IExternalToolboxLoader.Load(string filename) { TargetRuntime runtime = Runtime.SystemAssemblyService.CurrentRuntime; List <ItemToolboxNode> list = new List <ItemToolboxNode> (); System.Reflection.Assembly scanAssem; try { if (runtime is MsNetTargetRuntime) { scanAssem = System.Reflection.Assembly.ReflectionOnlyLoadFrom(filename); } else { scanAssem = System.Reflection.Assembly.LoadFile(filename); } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError("ToolboxItemToolboxLoader: Could not load assembly '" + filename + "'", ex); return(list); } SystemPackage package = runtime.AssemblyContext.GetPackageFromPath(filename); //need to initialise if this if out of the main process //in order to be able to load icons etc. if (!initialized) { Gtk.Application.Init(); initialized = true; } //detect the runtime version MonoDevelop.Core.ClrVersion clrVersion = MonoDevelop.Core.ClrVersion.Default; byte[] corlibKey = new byte[] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 }; //the other system.{...} key: //{ 0xb0, 0x3f, 0x5f, 0x7f, 0x11, 0xd5, 0x0a, 0x3a }; foreach (System.Reflection.AssemblyName an in scanAssem.GetReferencedAssemblies()) { if (an.Name == "mscorlib" && byteArraysEqual(corlibKey, an.GetPublicKeyToken())) { if (an.Version == new Version(2, 0, 0, 0)) { clrVersion = MonoDevelop.Core.ClrVersion.Net_2_0; break; } else if (an.Version == new Version(1, 0, 5000, 0)) { clrVersion = MonoDevelop.Core.ClrVersion.Net_1_1; break; } } } if (clrVersion == MonoDevelop.Core.ClrVersion.Default) { MonoDevelop.Core.LoggingService.LogError("ToolboxItemToolboxLoader: assembly '" + filename + "' references unknown runtime version."); return(list); } Type[] types = scanAssem.GetTypes(); foreach (Type t in types) { //skip inaccessible types if (t.IsAbstract || !t.IsPublic || !t.IsClass) { continue; } //get the ToolboxItemAttribute if present object[] atts = t.GetCustomAttributes(typeof(ToolboxItemAttribute), true); if (atts == null || atts.Length == 0) { continue; } ToolboxItemAttribute tba = (ToolboxItemAttribute)atts[0]; if (tba.Equals(ToolboxItemAttribute.None) || tba.ToolboxItemType == null) { continue; } // Technically CategoryAttribute shouldn't be used for this purpose (intended for properties in // the PropertyGrid) but I can see no harm in doing this. string cat = null; atts = t.GetCustomAttributes(typeof(CategoryAttribute), true); if (atts != null && atts.Length > 0) { cat = ((CategoryAttribute)atts[0]).Category; } try { ItemToolboxNode node = GetNode(t, tba, cat, package != null? filename : null, clrVersion); if (node != null) { // Make sure this item is only shown for the correct runtime node.ItemFilters.Add(new ToolboxItemFilterAttribute("TargetRuntime." + runtime.Id, ToolboxItemFilterType.Require)); list.Add(node); } } catch (Exception ex) { MonoDevelop.Core.LoggingService.LogError( "Unhandled error in toolbox node loader '" + GetType().FullName + "' with type '" + t.FullName + "' in assembly '" + scanAssem.FullName + "'", ex); } } return(list);// Load (scanAssem); }