Exemplo n.º 1
0
        /// <summary>
        /// Load currently known assemblies
        /// </summary>
        private void LoadAssemblies()
        {
            lock (Locker)
            {
                //Clear current
                LoadedAssemblies.Clear();

                //Get all from current assembly directory
                var executableLocation = Assembly.GetEntryAssembly().Location;
                var path = Path.Combine(Path.GetDirectoryName(executableLocation));
                LoadedAssemblies.AddRange(GetAssemblies(path));

                //Get all from plug-ins locations
                string custompath = Config.GlobalConfig.AssembliesPath;

                //Check if path exists for reporting
                if (!string.IsNullOrWhiteSpace(custompath) && !Directory.Exists(custompath))
                {
                    _log.Warn($"Cannot load custom assemblies path, path does not exist {custompath}");
                }

                //Load
                if (!string.IsNullOrWhiteSpace(custompath) && Directory.Exists(custompath) && path != custompath)
                {
                    var found = GetAssemblies(custompath);
                    LoadedAssemblies.AddRange(found.Where(x => !LoadedAssemblies.Select(n => n.Location).Contains(x.Location)));
                }

                //Load container
                Container = new ContainerConfiguration().WithAssemblies(LoadedAssemblies);
            }
        }