示例#1
0
 public ToolComponent(string fullName, ComponentAssembly assembly, bool enabled)
 {
     this.fullName     = fullName;
     this.assemblyName = assembly.Name;
     this.hintPath     = assembly.HintPath;
     this.isEnabled    = enabled;
 }
示例#2
0
        public void SaveToolComponentLibrary(string fileName)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<SharpDevelopControlLibrary version=\"" + VERSION + "\"/>");
            Hashtable assemblyHashTable = new Hashtable();

            XmlElement assemblyNode = doc.CreateElement("Assemblies");

            doc.DocumentElement.AppendChild(assemblyNode);
            for (int i = 0; i < assemblies.Count; ++i)
            {
                ComponentAssembly componentAssembly = (ComponentAssembly)assemblies[i];
                assemblyHashTable[componentAssembly.Name] = i;

                XmlElement newAssembly = doc.CreateElement("Assembly");

                newAssembly.SetAttribute("assembly", componentAssembly.Name);
                if (componentAssembly.HintPath != null)
                {
                    newAssembly.SetAttribute("path", componentAssembly.HintPath);
                }
                assemblyNode.AppendChild(newAssembly);
            }

            XmlElement categoryNode = doc.CreateElement("Categories");

            doc.DocumentElement.AppendChild(categoryNode);
            foreach (Category category in categories)
            {
                XmlElement newCategory = doc.CreateElement("Category");
                newCategory.SetAttribute("name", category.Name);
                newCategory.SetAttribute("enabled", category.IsEnabled.ToString());
                categoryNode.AppendChild(newCategory);

                foreach (ToolComponent component in category.ToolComponents)
                {
                    XmlElement newToolComponent = doc.CreateElement("ToolComponent");
                    newToolComponent.SetAttribute("class", component.FullName);

                    if (assemblyHashTable[component.AssemblyName] == null)
                    {
                        XmlElement newAssembly = doc.CreateElement("Assembly");
                        newAssembly.SetAttribute("assembly", component.AssemblyName);
                        if (component.HintPath != null)
                        {
                            newAssembly.SetAttribute("path", component.HintPath);
                        }

                        assemblyNode.AppendChild(newAssembly);
                        assemblyHashTable[component.AssemblyName] = assemblyHashTable.Values.Count;
                    }

                    newToolComponent.SetAttribute("assembly", assemblyHashTable[component.AssemblyName].ToString());
                    newToolComponent.SetAttribute("enabled", component.IsEnabled.ToString());
                    newCategory.AppendChild(newToolComponent);
                }
            }
            doc.Save(fileName);
        }