Exemple #1
0
        private bool DiscoverRuntimePlugin(PluginManifest manifest, Assembly assembly)
        {
            var hasSpecificType = !string.IsNullOrEmpty(manifest.PluginTypeName);
            var pluginType      = hasSpecificType
                ? assembly.GetType(manifest.PluginTypeName)
                : null;

            if (hasSpecificType && pluginType == null)
            {
                return(false);
            }

            var activator = pluginType == null ? _pluginActivator : DefaultPluginActivator(pluginType);
            var plugin    = activator.Invoke(manifest, assembly);

            if (plugin != null)
            {
                manifest.RuntimeInfo.Plugin         = plugin;
                manifest.RuntimeInfo.PluginAssembly = assembly;
                manifest.RuntimeInfo.PluginType     = plugin.GetType();

                if (!_pluginAssemblies.Contains(assembly))
                {
                    _pluginAssemblies.Add(assembly);
                }
            }
            return(manifest.RuntimeInfo.Plugin != null);
        }
Exemple #2
0
 private static void ValidateMinVersionCompatibility(PluginDependency dependency, PluginManifest dependencyManifest,
                                                     List <string> errorMessages)
 {
     if (dependency.MinVersion != null && dependency.MinVersion != default(Version) &&
         (dependencyManifest.PluginVersion == null ||
          dependency.MinVersion > dependencyManifest.PluginVersion))
     {
         errorMessages.Add(
             string.Format(ErrorMessages.PluginDependencyMinVersionConflictFormat,
                           dependency.PluginId,
                           dependencyManifest.PluginVersion == null
                     ? ""
                     : dependencyManifest.PluginVersion.ToString(3),
                           dependency.MinVersion.ToString(3)));
     }
 }
Exemple #3
0
 private static void ValidateVersionCompatibility(PluginDependency dependency, PluginManifest dependencyManifest,
                                                  List <string> errorMessages)
 {
     ValidateMinVersionCompatibility(dependency, dependencyManifest, errorMessages);
     ValidateMaxVersionCompatibility(dependency, dependencyManifest, errorMessages);
 }
Exemple #4
0
 public abstract Task SavePluginManifestAsync(PluginManifest manifest);