예제 #1
0
        /// <summary>
        /// </summary>
        /// <param name="filesystem"></param>
        /// <param name="path"></param>
        public PluginArchiveLoader(IFilesystem filesystem, string path)
        {
            _filesystem = filesystem;
            _plugins    = new Dictionary <PluginId, PluginGroup>();

            try
            {
                // TODO: How would we make this truly async? Currently the app has to block until all plugins are loaded wich is sad
                var files = filesystem.EnumerateFiles(path, string.Format("*.{0}", PluginArchive.PluginExtension))
                            .Result;
                foreach (var pluginPath in files)
                {
                    TryOpenPlugin(pluginPath);
                }

                foreach (var plugin in _plugins.Values)
                {
                    plugin.Load();
                }
            }
            catch (DirectoryNotFoundException e)
            {
                Log.WarnFormat("Unable to find plugins in '{0}': {1}", path, e);
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Unable to find plugins in '{0}': {1}", path, e);
            }
        }
예제 #2
0
        private IReadOnlyList <string> EnumerateFilesPrivate(string wildcardPattern)
        {
            var path         = Path.GetDirectoryName(wildcardPattern);
            var fileName     = Path.GetFileName(wildcardPattern);
            var absolutePath = Core.Paths.NormalizeAndEvaluate(path, _filesystem.CurrentDirectory);
            var files        = _filesystem.EnumerateFiles(absolutePath, fileName, SearchOption.TopDirectoryOnly,
                                                          tolerateNonExistantPath: true);

            return(files);
        }
예제 #3
0
        public Task DeleteFilesAsync(string filePathPattern)
        {
            var path     = Path.GetDirectoryName(filePathPattern);
            var fileName = Path.GetFileName(filePathPattern);

            var absolutePath = NormalizeAndEvaluate(path);
            var files        = _filesystem.EnumerateFiles(absolutePath, fileName, SearchOption.TopDirectoryOnly, tolerateNonExistantPath: true);

            foreach (var file in files)
            {
                DeleteFile(file);
            }

            return(Task.FromResult(42));
        }
예제 #4
0
 private void TryLoadPluginsFrom(IFilesystem filesystem, string path)
 {
     try
     {
         var files = filesystem.EnumerateFiles(path, string.Format("*.{0}", PluginArchive.PluginExtension));
         foreach (var pluginPath in files)
         {
             TryOpenPlugin(pluginPath);
         }
     }
     catch (DirectoryNotFoundException e)
     {
         Log.WarnFormat("Unable to find plugins in '{0}': {1}", path, e);
     }
     catch (Exception e)
     {
         Log.ErrorFormat("Unable to find plugins in '{0}': {1}", path, e);
     }
 }
예제 #5
0
            public Task <IReadOnlyList <string> > EnumerateSnapshots()
            {
                var pattern = string.Format("*.{0}", Constants.SnapshotExtension);

                return(_filesystem.EnumerateFiles(Constants.SnapshotDirectory, pattern));
            }