/// <summary>
        /// Scans for plugins in a custom location
        /// </summary>
        /// <param name="dir">Directory to scan</param>
        /// <remarks>
        /// <para>
        /// Scanning looks for files with a <em>.dll</em> extension, loads them and then searches for types implementing the <see cref="IConnectionDefinition">IConnectionDefinition</see> interface
        /// </para>
        /// </remarks>
        public static void ScanPlugins(String dir)
        {
            //Then find types in Plugin assemblies
            if (Directory.Exists(dir))
            {
                foreach (String file in Directory.GetFiles(dir))
                {
                    switch (Path.GetExtension(file))
                    {
                    case ".dll":
                        try
                        {
                            Assembly assm = Assembly.LoadFrom(file);
                            ConnectionDefinitionManager.DiscoverTypes(assm);
                        }
                        catch
                        {
                            //Ignore errors in loading assemblies
                        }
                        break;

                    default:
                        continue;
                    }
                }
            }
        }
        private static void Init()
        {
            if (!_init)
            {
                //First find all types in this assembly
                Assembly assm = Assembly.GetExecutingAssembly();
                ConnectionDefinitionManager.DiscoverTypes(assm);

                //Then scan for plugins
                ScanPlugins();

                _init = true;
            }
        }
Esempio n. 3
0
        private static void Init()
        {
            if (!_init)
            {
                //First find all types in this assembly
                Assembly assm = Assembly.GetExecutingAssembly();
                ConnectionDefinitionManager.DiscoverTypes(assm);

                //Then find types in Plugin assemblies
                if (Directory.Exists("plugins"))
                {
                    foreach (String file in Directory.GetFiles("plugins"))
                    {
                        switch (Path.GetExtension(file))
                        {
                        case ".dll":
                            try
                            {
                                assm = Assembly.LoadFrom(file);
                                ConnectionDefinitionManager.DiscoverTypes(assm);
                            }
                            catch (Exception ex)
                            {
                                //Ignore errors in loading assemblies
                            }
                            break;

                        default:
                            continue;
                        }
                    }
                }

                _init = true;
            }
        }