/// <summary> /// Copies data from another node attribute. /// </summary> /// <param name='att'> /// The attribute from which to copy. /// </param> public void CopyFrom(NodeTypeAttribute att) { name = att.name; type = att.type; required = att.required; localizable = att.localizable; description = att.description; }
/// <summary> /// Copies data from another node attribute. /// </summary> /// <param name='att'> /// The attribute from which to copy. /// </param> public void CopyFrom (NodeTypeAttribute att) { name = att.name; type = att.type; required = att.required; localizable = att.localizable; description = att.description; }
/// <summary> /// Copies data from another node set /// </summary> public void CopyFrom(ExtensionNodeType ntype) { base.CopyFrom(ntype); this.typeName = ntype.TypeName; this.objectTypeName = ntype.ObjectTypeName; this.description = ntype.Description; this.addinId = ntype.AddinId; Attributes.Clear(); foreach (NodeTypeAttribute att in ntype.Attributes) { NodeTypeAttribute catt = new NodeTypeAttribute(); catt.CopyFrom(att); Attributes.Add(catt); } }
void ScanNodeType(IAssemblyReflector reflector, AddinDescription config, ExtensionNodeType nt, ArrayList assemblies, Hashtable internalNodeSets) { if (nt.TypeName.Length == 0) nt.TypeName = "Mono.Addins.TypeExtensionNode"; object ntype = FindAddinType (reflector, nt.TypeName, assemblies); if (ntype == null) return; // Add type information declared with attributes in the code ExtensionNodeAttribute nodeAtt = (ExtensionNodeAttribute) reflector.GetCustomAttribute (ntype, typeof(ExtensionNodeAttribute), true); if (nodeAtt != null) { if (nt.Id.Length == 0 && nodeAtt.NodeName.Length > 0) nt.Id = nodeAtt.NodeName; if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0) nt.Description = nodeAtt.Description; if (nt.ExtensionAttributeTypeName.Length == 0 && nodeAtt.ExtensionAttributeTypeName.Length > 0) nt.ExtensionAttributeTypeName = nodeAtt.ExtensionAttributeTypeName; } else { // Use the node type name as default name if (nt.Id.Length == 0) nt.Id = reflector.GetTypeName (ntype); } // Add information about attributes object[] fieldAtts = reflector.GetCustomAttributes (ntype, typeof(NodeAttributeAttribute), true); foreach (NodeAttributeAttribute fatt in fieldAtts) { NodeTypeAttribute natt = new NodeTypeAttribute (); natt.Name = fatt.Name; natt.Required = fatt.Required; if (fatt.TypeName != null) natt.Type = fatt.TypeName; if (fatt.Description.Length > 0) natt.Description = fatt.Description; nt.Attributes.Add (natt); } // Check if the type has NodeAttribute attributes applied to fields. foreach (object field in reflector.GetFields (ntype)) { NodeAttributeAttribute fatt = (NodeAttributeAttribute) reflector.GetCustomAttribute (field, typeof(NodeAttributeAttribute), false); if (fatt != null) { NodeTypeAttribute natt = new NodeTypeAttribute (); if (fatt.Name.Length > 0) natt.Name = fatt.Name; else natt.Name = reflector.GetFieldName (field); if (fatt.Description.Length > 0) natt.Description = fatt.Description; natt.Type = reflector.GetFieldTypeFullName (field); natt.Required = fatt.Required; nt.Attributes.Add (natt); } } // Check if the extension type allows children by looking for [ExtensionNodeChild] attributes. // First of all, look in the internalNodeSets hashtable, which is being used as cache string childSet = (string) internalNodeSets [nt.TypeName]; if (childSet == null) { object[] ats = reflector.GetCustomAttributes (ntype, typeof(ExtensionNodeChildAttribute), true); if (ats.Length > 0) { // Create a new node set for this type. It is necessary to create a new node set // instead of just adding child ExtensionNodeType objects to the this node type // because child types references can be recursive. ExtensionNodeSet internalSet = new ExtensionNodeSet (); internalSet.Id = reflector.GetTypeName (ntype) + "_" + Guid.NewGuid().ToString (); foreach (ExtensionNodeChildAttribute at in ats) { ExtensionNodeType internalType = new ExtensionNodeType (); internalType.Id = at.NodeName; internalType.TypeName = at.ExtensionNodeTypeName; internalSet.NodeTypes.Add (internalType); } config.ExtensionNodeSets.Add (internalSet); nt.NodeSets.Add (internalSet.Id); // Register the new set in a hashtable, to allow recursive references to the // same internal set. internalNodeSets [nt.TypeName] = internalSet.Id; internalNodeSets [reflector.GetTypeAssemblyQualifiedName (ntype)] = internalSet.Id; ScanNodeSet (reflector, config, internalSet, assemblies, internalNodeSets); } } else { if (childSet.Length == 0) { // The extension type does not declare children. return; } // The extension type can have children. The allowed children are // defined in this extension set. nt.NodeSets.Add (childSet); return; } ScanNodeSet (reflector, config, nt, assemblies, internalNodeSets); }
public NodeTypeAttributeCompletionData (NodeTypeAttribute att) { this.att = att; }
/// <summary> /// Copies data from another node set /// </summary> public void CopyFrom (ExtensionNodeType ntype) { base.CopyFrom (ntype); this.typeName = ntype.TypeName; this.objectTypeName = ntype.ObjectTypeName; this.description = ntype.Description; this.addinId = ntype.AddinId; Attributes.Clear (); foreach (NodeTypeAttribute att in ntype.Attributes) { NodeTypeAttribute catt = new NodeTypeAttribute (); catt.CopyFrom (att); Attributes.Add (catt); } }