コード例 #1
0
ファイル: PluginGroup.cs プロジェクト: Starigazdam/Tailviewer
        public static List <PluginError> FindCompatibilityErrors(IPluginPackageIndex index)
        {
            var errors = new List <PluginError>();

            if (index.PluginArchiveVersion < PluginArchive.MinimumSupportedPluginArchiveVersion)
            {
                errors.Add(new
                           PluginError("The plugin targets an older version of Tailviewer and must be compiled against the current version in order to be usable"));
            }

            if (index.PluginArchiveVersion > PluginArchive.CurrentPluginArchiveVersion)
            {
                errors.Add(new
                           PluginError("The plugin targets a newer version of Tailviewer and must be compiled against the current version in order to be usable"));
            }

            if (index.ImplementedPluginInterfaces != null)
            {
                foreach (var implementation in index.ImplementedPluginInterfaces)
                {
                    if (TryResolvePluginInterface(implementation, out var @interface))
                    {
                        var currentInterfaceVersion     = PluginInterfaceVersionAttribute.GetInterfaceVersion(@interface);
                        var implementedInterfaceVersion = new PluginInterfaceVersion(implementation.InterfaceVersion);

                        if (implementedInterfaceVersion < currentInterfaceVersion)
                        {
                            errors.Add(new
                                       PluginError($"The plugin implements an older version of '{@interface.FullName}'. It must target the current version in order to be usable!"));
                        }
                        else if (implementedInterfaceVersion > currentInterfaceVersion)
                        {
                            errors.Add(new
                                       PluginError($"The plugin implements a newer version of '{@interface.FullName}'. It must target the current version in order to be usable!"));
                        }
                    }
                    else
                    {
                        // If a plugin unfortunately implements an interface that is not known to this tailviewer,
                        // then it is bad news because that means we won't be able to load its assembly!
                        errors.Add(new
                                   PluginError($"The plugin implements an unknown interface '{implementation.InterfaceTypename}' which is probably part of a newer tailviewer version. The plugin should target the current version in order to be usable!"));
                    }
                }
            }

            return(errors);
        }
コード例 #2
0
 public PluginImplementationDescription(PluginInterfaceImplementation description)
 {
     FullTypeName = description.ImplementationTypename;
     Version      = new PluginInterfaceVersion(description.InterfaceVersion);
 }