Exemplo n.º 1
0
 public void LoadPlugins()
 {
     Clear();
     //
     if (!Directory.Exists(m_pluginsDir))
     {
         GC.Collect();
         return;
     }
     //
     try
     {
         FileInfo fi = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
         m_appDir = fi.DirectoryName;
         //
         foreach (string f in Directory.GetFiles(m_pluginsDir, "*.dll"))
         {
             AppDomain domain = DomainHelper.CreateDomain(m_appDir, m_pluginsDir);
             //
             T[] types = LoadFrom(domain, f);
             if ((types == null) || (types.Length <= 0))
             {
                 DomainHelper.UnloadDomain(domain);
                 continue;
             }
             //
             for (int i = 0; i < types.Length; i++)
             {
                 PluginInfo <T> pi = new PluginInfo <T>(types[i], domain, CommonDll);
                 m_pluginList.Add(pi);
             }
         }
     }
     catch
     {             // ошибки доступа к файлам
     }
     finally
     {
         GC.Collect();
     }
 }