Beispiel #1
0
        private Type GetPlugin(string baseName, string name, string attname)
        {
            Hashtable hashtable = this.GetPluginCache();

            name = name.ToLower();
            Type type = hashtable[name] as Type;

            if (type == null)
            {
                if (PluginContainer.pluginCache.Get(this.IndexCacheKey) == null)
                {
                    return(null);
                }
                XmlDocument xmlDocument = PluginContainer.pluginCache.Get(this.IndexCacheKey) as XmlDocument;
                XmlNode     xmlNode     = xmlDocument.DocumentElement.SelectSingleNode("//" + baseName + "/item[@" + attname + "='" + name + "']");
                if (xmlNode == null || !File.Exists(xmlNode.Attributes["file"].Value))
                {
                    return(null);
                }
                Assembly assembly = Assembly.Load(PluginContainer.LoadPlugin(xmlNode.Attributes["file"].Value));
                type = assembly.GetType(xmlNode.Attributes["identity"].Value, false, true);
                if (type != null)
                {
                    hashtable[name] = type;
                }
            }
            return(type);
        }
Beispiel #2
0
        private void BuildIndex(XmlDocument catalog, XmlNode mapNode)
        {
            if (!Directory.Exists(this.PluginLocalPath))
            {
                return;
            }
            string[] files    = Directory.GetFiles(this.PluginLocalPath, "*.dll", SearchOption.AllDirectories);
            string   fullName = typeof(IPlugin).FullName;

            string[] array = files;
            for (int i = 0; i < array.Length; i++)
            {
                string   filename      = array[i];
                Assembly assembly      = Assembly.Load(PluginContainer.LoadPlugin(filename));
                Type[]   exportedTypes = assembly.GetExportedTypes();
                for (int j = 0; j < exportedTypes.Length; j++)
                {
                    Type type_ = exportedTypes[j];
                    if (PluginContainer.CheckIsPlugin(type_, fullName))
                    {
                        this.AddPlugin(type_, filename, catalog, mapNode);
                    }
                }
            }
        }
Beispiel #3
0
 private void BuildIndex(XmlDocument catalog, XmlNode mapNode)
 {
     if (Directory.Exists(this.PluginLocalPath))
     {
         string[] files    = Directory.GetFiles(this.PluginLocalPath, "*.dll", SearchOption.AllDirectories);
         string   fullName = typeof(IPlugin).FullName;
         string[] array    = files;
         foreach (string filename in array)
         {
             Assembly assembly      = Assembly.Load(PluginContainer.LoadPlugin(filename));
             Type[]   exportedTypes = assembly.GetExportedTypes();
             foreach (Type t in exportedTypes)
             {
                 if (PluginContainer.CheckIsPlugin(t, fullName))
                 {
                     this.AddPlugin(t, filename, catalog, mapNode);
                 }
             }
         }
     }
 }