예제 #1
0
 public void LoadConfig()
 {
     if (!this.configFile.Exists)
         return;
     PluginsXmlDocument pluginsXmlDocument = new PluginsXmlDocument();
     ((XmlDocument)pluginsXmlDocument).Load(this.configFile.FullName);
     IEnumerator enumerator = pluginsXmlDocument.Plugins.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             PluginXmlNode pluginXmlNode = (PluginXmlNode)enumerator.Current;
             PluginInfo plugin = new PluginInfo(pluginXmlNode.PluginType, pluginXmlNode.TypeName.Value, pluginXmlNode.AssemblyName.Value);
             plugin.Enabled = pluginXmlNode.Enabled;
             if (pluginXmlNode.X86.HasValue)
                 plugin.x86 = pluginXmlNode.X86.Value;
             if (pluginXmlNode.X64.HasValue)
                 plugin.x64 = pluginXmlNode.X64.Value;
             this.plugins.Add(plugin);
         }
     }
     finally
     {
         IDisposable disposable = enumerator as IDisposable;
         if (disposable != null)
             disposable.Dispose();
     }
 }
예제 #2
0
 public bool TryGet(ref PluginInfo plugin)
 {
     PluginInfo pluginInfo;
     if (!this.plugins.TryGetValue(this.GetPluginKey(plugin), out pluginInfo))
         return false;
     plugin = pluginInfo;
     return true;
 }
예제 #3
0
		public PluginOQViewItem(PluginInfo plugin)      : base(new string[2])
		{
			this.plugin = plugin;
			this.SubItems[0].Text = plugin.TypeName;
			this.SubItems[1].Text = plugin.AssemblyName;
			this.Checked = plugin.Enabled;
			this.UpdateIcon();
		}
예제 #4
0
 public void LoadPlugin(PluginInfo plugin)
 {
     try
     {
         object obj = plugin.Load();
         if (plugin.PluginType != PluginType.UserProvider)
             return;
         FieldInfo field = typeof(UserProvider).GetField("provider", BindingFlags.Instance | BindingFlags.NonPublic);
         if (field == null)
             return;
         ProviderManager.Add((IProvider)field.GetValue(obj));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
예제 #5
0
 public void LoadConfig()
 {
     if (!this.configFile.Exists)
         return;
     PluginsXmlDocument doc = new PluginsXmlDocument();
     doc.Load(this.configFile.FullName);
     foreach (PluginXmlNode node in doc.Plugins)
     {
         PluginInfo plugin = new PluginInfo(node.PluginType, node.TypeName.Value, node.AssemblyName.Value);
         plugin.Enabled = node.Enabled;
         if (node.X86.HasValue)
             plugin.x86 = node.X86.Value;
         if (node.X64.HasValue)
             plugin.x64 = node.X64.Value;
         this.plugins.Add(plugin);
     }
 }
예제 #6
0
 private string GetPluginKey(PluginInfo plugin)
 {
     return(string.Format("{0}, {1}", plugin.TypeName, plugin.AssemblyName));
 }
예제 #7
0
 public void Remove(PluginInfo plugin)
 {
     this.plugins.Remove(this.GetPluginKey(plugin));
 }
예제 #8
0
 public void Add(PluginInfo plugin)
 {
     this.plugins.Add(this.GetPluginKey(plugin), plugin);
 }
예제 #9
0
 public bool Contains(PluginInfo plugin)
 {
     return(this.plugins.ContainsKey(this.GetPluginKey(plugin)));
 }
예제 #10
0
 private string GetPluginKey(PluginInfo plugin)
 {
     return string.Format("{0}, {1}", plugin.TypeName, plugin.AssemblyName);
 }
예제 #11
0
 public void Remove(PluginInfo plugin)
 {
     this.plugins.Remove(this.GetPluginKey(plugin));
 }
예제 #12
0
 public bool Contains(PluginInfo plugin)
 {
     return this.plugins.ContainsKey(this.GetPluginKey(plugin));
 }
예제 #13
0
 public void Add(PluginInfo plugin)
 {
     this.plugins.Add(this.GetPluginKey(plugin), plugin);
 }
예제 #14
0
 private bool Equals(PluginInfo plugin1, PluginInfo plugin2)
 {
   if (plugin1.TypeName == plugin2.TypeName)
     return plugin1.AssemblyName == plugin2.AssemblyName;
   else
     return false;
 }
예제 #15
0
 private PluginInfo[] ExtractPlugins(string filename, PluginType pluginType)
 {
   List<PluginInfo> list = new List<PluginInfo>();
   System.Type pluginBaseType = Global.PluginManager.GetPluginBaseType(pluginType);
   try
   {
     AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(this.CurrentDomain_ReflectionOnlyAssemblyResolve);
     Assembly assembly = Assembly.ReflectionOnlyLoad(AssemblyName.GetAssemblyName(filename).FullName);
     foreach (System.Type type in assembly.GetTypes())
     {
       if (type.BaseType != (System.Type) null && type.BaseType.GUID == pluginBaseType.GUID)
       {
         PluginInfo pluginInfo = new PluginInfo(pluginType, type.FullName, assembly.GetName().Name);
         list.Add(pluginInfo);
       }
     }
   }
   catch (Exception ex)
   {
     int num = (int) MessageBox.Show((IWin32Window) this, ((object) ex).ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     list.Clear();
   }
   finally
   {
     AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= new ResolveEventHandler(this.CurrentDomain_ReflectionOnlyAssemblyResolve);
   }
   return list.ToArray();
 }
예제 #16
0
 private bool IsPluginInUse(PluginInfo plugin)
 {
   return this.IsPluginInUse(plugin.TypeName, plugin.AssemblyName);
 }