Ejemplo n.º 1
0
        internal virtual XmlDocument GetMetaData()
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml("<xml></xml>");
            PropertyInfo[] properties = base.GetType().GetProperties();
            PropertyInfo[] array      = properties;
            for (int i = 0; i < array.Length; i++)
            {
                PropertyInfo           propertyInfo           = array[i];
                ConfigElementAttribute configElementAttribute = (ConfigElementAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(ConfigElementAttribute));
                if (configElementAttribute != null)
                {
                    ConfigablePlugin.AppendAttrubiteNode(xmlDocument, configElementAttribute, propertyInfo);
                }
            }
            return(xmlDocument);
        }
Ejemplo n.º 2
0
        internal virtual XmlDocument GetMetaData()
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.XmlResolver = null;
            xmlDocument.LoadXml("<xml></xml>");
            PropertyInfo[] properties = base.GetType().GetProperties();
            PropertyInfo[] array      = properties;
            foreach (PropertyInfo propertyInfo in array)
            {
                ConfigElementAttribute configElementAttribute = (ConfigElementAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(ConfigElementAttribute));
                if (configElementAttribute != null)
                {
                    ConfigablePlugin.AppendAttrubiteNode(xmlDocument, configElementAttribute, propertyInfo);
                }
            }
            return(xmlDocument);
        }
        private void AddPlugin(Type t, string filename, XmlDocument catalog, XmlNode mapNode)
        {
            XmlNode newChild = mapNode.SelectSingleNode(t.BaseType.Name);

            if (newChild == null)
            {
                newChild = catalog.CreateElement(t.BaseType.Name);
                mapNode.AppendChild(newChild);
            }
            XmlNode      node2 = catalog.CreateElement("item");
            XmlAttribute node  = catalog.CreateAttribute("identity");

            node.Value = t.FullName.ToLower();
            node2.Attributes.Append(node);
            XmlAttribute attribute2 = catalog.CreateAttribute("file");

            attribute2.Value = filename;
            node2.Attributes.Append(attribute2);
            PluginAttribute customAttribute = (PluginAttribute)Attribute.GetCustomAttribute(t, typeof(PluginAttribute));

            if (customAttribute != null)
            {
                XmlAttribute attribute4 = catalog.CreateAttribute("name");
                attribute4.Value = customAttribute.Name;
                node2.Attributes.Append(attribute4);
                XmlAttribute attribute5 = catalog.CreateAttribute("seq");
                attribute5.Value = (customAttribute.Sequence > 0) ? customAttribute.Sequence.ToString(CultureInfo.InvariantCulture) : "0";
                node2.Attributes.Append(attribute5);
                ConfigablePlugin plugin     = Activator.CreateInstance(t) as ConfigablePlugin;
                XmlAttribute     attribute6 = catalog.CreateAttribute("logo");
                if (string.IsNullOrEmpty(plugin.Logo) || (plugin.Logo.Trim().Length == 0))
                {
                    attribute6.Value = "";
                }
                else
                {
                    attribute6.Value = this.PluginVirtualPath + "/images/" + plugin.Logo.Trim();
                }
                node2.Attributes.Append(attribute6);
                XmlAttribute attribute7 = catalog.CreateAttribute("shortDescription");
                attribute7.Value = plugin.ShortDescription;
                node2.Attributes.Append(attribute7);
                XmlAttribute attribute8 = catalog.CreateAttribute("description");
                attribute8.Value = plugin.Description;
                node2.Attributes.Append(attribute8);
            }
            XmlAttribute attribute9 = catalog.CreateAttribute("namespace");

            attribute9.Value = t.Namespace.ToLower();
            node2.Attributes.Append(attribute9);
            if ((customAttribute != null) && (customAttribute.Sequence > 0))
            {
                XmlNode refChild = FindNode(newChild.ChildNodes, customAttribute.Sequence);
                if (refChild == null)
                {
                    newChild.AppendChild(node2);
                }
                else
                {
                    newChild.InsertBefore(node2, refChild);
                }
            }
            else
            {
                newChild.AppendChild(node2);
            }
        }
Ejemplo n.º 4
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);
            }
        }