Пример #1
0
        public IEnumerable <IPluginWithDescription <T> > LoadAllOfTypeFrom <T>(PluginId id) where T : class, IPlugin
        {
            if (!_plugins.TryGetValue(id, out var plugin))
            {
                return(Enumerable.Empty <PluginWithDescription <T> >());
            }

            return(plugin.LoadAllOfType <T>());
        }
Пример #2
0
 public EmptyPluginArchive(PluginId id, Version pluginVersion)
 {
     _index = new PluginPackageIndex
     {
         Id = id.Value,
         PluginArchiveVersion = PluginArchive.CurrentPluginArchiveVersion,
         Version = pluginVersion.ToString()
     };
 }
Пример #3
0
 public PluginGroup(PluginId id)
 {
     _id = id;
     _pluginsByVersion = new Dictionary <Version, Plugin>();
     _status           = new PluginStatus
     {
         IsInstalled = false,
         IsLoaded    = false
     };
 }
Пример #4
0
        private void Add(string pluginPath, PluginId id, Version pluginVersion, IPluginArchive archive)
        {
            if (!_plugins.TryGetValue(id, out var pluginGroup))
            {
                pluginGroup = new PluginGroup(id);
                _plugins.Add(id, pluginGroup);
            }

            pluginGroup.Add(pluginPath, pluginVersion, archive);
        }
Пример #5
0
        public IPluginStatus GetStatus(PluginId id)
        {
            if (id != null && _plugins.TryGetValue(id, out var group))
            {
                return(group.Status);
            }

            return(new PluginStatus
            {
                IsInstalled = false
            });
        }
Пример #6
0
        private PluginGroup Add(string pluginPath, IPluginArchive archive)
        {
            var id = new PluginId(archive.Index.Id);

            if (!_plugins.TryGetValue(id, out var pluginGroup))
            {
                pluginGroup = new PluginGroup(id);
                _plugins.Add(id, pluginGroup);
            }

            var version = archive.Index.Version;

            pluginGroup.Add(pluginPath, version, archive);
            return(pluginGroup);
        }
Пример #7
0
        public static void ExtractIdAndVersion(string pluginPath, out PluginId id, out Version version)
        {
            var fileName       = Path.GetFileNameWithoutExtension(pluginPath);
            var tokens         = fileName.Split('.').ToList();
            var versionNumbers = new List <int>();

            for (var i = tokens.Count - 1; i >= 0; --i)
            {
                if (int.TryParse(tokens[i], NumberStyles.Integer, CultureInfo.InvariantCulture, out var versionNumber))
                {
                    versionNumbers.Insert(index: 0, item: versionNumber);
                    tokens.RemoveAt(i);
                }
            }

            if (tokens.Count == 0)
            {
                id = new PluginId("Unknown");
            }
            else
            {
                id = new PluginId(string.Join(".", tokens));
            }

            switch (versionNumbers.Count)
            {
            case 4:
                version = new Version(versionNumbers[index: 0], versionNumbers[index: 1], versionNumbers[index: 2],
                                      versionNumbers[index: 3]);
                break;

            case 3:
                version = new Version(versionNumbers[index: 0], versionNumbers[index: 1], versionNumbers[index: 2]);
                break;

            case 2:
                version = new Version(versionNumbers[index: 0], versionNumbers[index: 1]);
                break;

            case 1:
                version = new Version(versionNumbers[index: 0], minor: 0);
                break;

            default:
                version = new Version(major: 0, minor: 0, build: 0, revision: 0);
                break;
            }
        }
        public IPluginStatus GetStatus(PluginId id)
        {
            foreach (var pluginLoader in _pluginLoaders)
            {
                var status = pluginLoader.GetStatus(id);
                if (status.IsInstalled)
                {
                    return(status);
                }
            }

            return(new PluginStatus
            {
                IsInstalled = false,
                IsLoaded = false
            });
        }
Пример #9
0
        private static void ExtractIdAndVersion(string pluginPath, out PluginId id, out Version version)
        {
            var fileName = Path.GetFileNameWithoutExtension(pluginPath);
            int idx      = fileName.IndexOf(".");

            if (idx != -1)
            {
                id = new PluginId(fileName.Substring(0, idx));
                var tmp = fileName.Substring(idx + 1);
                if (!Version.TryParse(tmp, out version))
                {
                    version = new Version(0, 0, 0, 0);
                }
            }
            else
            {
                id      = new PluginId("Unknown");
                version = new Version(0, 0, 0, 0);
            }
        }
Пример #10
0
 public IPluginStatus GetStatus(PluginId id)
 {
     return(new PluginStatus());
 }
Пример #11
0
 public IPluginStatus GetStatus(PluginId id)
 {
     return(_pluginLoader.GetStatus(id));
 }
Пример #12
0
 public IPluginStatus GetStatus(PluginId id)
 {
     throw new NotImplementedException();
 }