Example #1
0
        private void AddPlugin(Type t, string filename, XmlDocument catalog, XmlNode mapNode)
        {
            XmlNode xmlNode = mapNode.SelectSingleNode(t.BaseType.Name);

            if (xmlNode == null)
            {
                xmlNode = catalog.CreateElement(t.BaseType.Name);
                mapNode.AppendChild(xmlNode);
            }
            XmlNode      xmlNode2     = catalog.CreateElement("item");
            XmlAttribute xmlAttribute = catalog.CreateAttribute("identity");

            xmlAttribute.Value = t.FullName.ToLower();
            xmlNode2.Attributes.Append(xmlAttribute);
            XmlAttribute xmlAttribute2 = catalog.CreateAttribute("file");

            xmlAttribute2.Value = filename;
            xmlNode2.Attributes.Append(xmlAttribute2);
            PluginAttribute pluginAttribute = (PluginAttribute)Attribute.GetCustomAttribute(t, typeof(PluginAttribute));

            if (pluginAttribute != null)
            {
                XmlAttribute xmlAttribute3 = catalog.CreateAttribute("name");
                xmlAttribute3.Value = pluginAttribute.Name;
                xmlNode2.Attributes.Append(xmlAttribute3);
                XmlAttribute xmlAttribute4 = catalog.CreateAttribute("seq");
                xmlAttribute4.Value = ((pluginAttribute.Sequence > 0) ? pluginAttribute.Sequence.ToString(CultureInfo.InvariantCulture) : "0");
                xmlNode2.Attributes.Append(xmlAttribute4);
                ConfigablePlugin configablePlugin = Activator.CreateInstance(t) as ConfigablePlugin;
                XmlAttribute     xmlAttribute5    = catalog.CreateAttribute("logo");
                if (string.IsNullOrEmpty(configablePlugin.Logo) || configablePlugin.Logo.Trim().Length == 0)
                {
                    xmlAttribute5.Value = "";
                }
                else
                {
                    xmlAttribute5.Value = this.PluginVirtualPath + "/images/" + configablePlugin.Logo.Trim();
                }
                xmlNode2.Attributes.Append(xmlAttribute5);
                XmlAttribute xmlAttribute6 = catalog.CreateAttribute("shortDescription");
                xmlAttribute6.Value = configablePlugin.ShortDescription;
                xmlNode2.Attributes.Append(xmlAttribute6);
                XmlAttribute xmlAttribute7 = catalog.CreateAttribute("description");
                xmlAttribute7.Value = configablePlugin.Description;
                xmlNode2.Attributes.Append(xmlAttribute7);
            }
            XmlAttribute xmlAttribute8 = catalog.CreateAttribute("namespace");

            xmlAttribute8.Value = t.Namespace.ToLower();
            xmlNode2.Attributes.Append(xmlAttribute8);
            if (pluginAttribute != null && pluginAttribute.Sequence > 0)
            {
                XmlNode xmlNode3 = PluginContainer.FindNode(xmlNode.ChildNodes, pluginAttribute.Sequence);
                if (xmlNode3 == null)
                {
                    xmlNode.AppendChild(xmlNode2);
                }
                else
                {
                    xmlNode.InsertBefore(xmlNode2, xmlNode3);
                }
            }
            else
            {
                xmlNode.AppendChild(xmlNode2);
            }
        }