public ServiceDescriptor(Registry registry, ServiceRegistration serviceRegistration)
 {
     this.registry = registry;
     pluginDescriptor = (PluginDescriptor) serviceRegistration.Plugin;
     serviceId = serviceRegistration.ServiceId;
     serviceTypeName = serviceRegistration.ServiceTypeName;
     defaultComponentTypeName = serviceRegistration.DefaultComponentTypeName;
     traitsHandlerFactory = serviceRegistration.TraitsHandlerFactory;
 }
 public ComponentDescriptor(Registry registry, ComponentRegistration componentRegistration)
 {
     this.registry = registry;
     pluginDescriptor = (PluginDescriptor) componentRegistration.Plugin;
     serviceDescriptor = (ServiceDescriptor) componentRegistration.Service;
     componentId = componentRegistration.ComponentId;
     componentTypeName = componentRegistration.ComponentTypeName ?? serviceDescriptor.DefaultComponentTypeName;
     componentProperties = componentRegistration.ComponentProperties.Copy().AsReadOnly();
     traitsProperties = componentRegistration.TraitsProperties.Copy().AsReadOnly();
     componentHandlerFactory = componentRegistration.ComponentHandlerFactory;
 }
 public PluginDependencyResolver(PluginDescriptor descriptor)
     : base(descriptor.registry.ServiceLocator, descriptor.registry.ResourceLocator)
 {
     this.descriptor = descriptor;
 }
Beispiel #4
0
 public void RegisterPlugin(PluginDescriptor plugin)
 {
     plugins = null;
     pluginsByPluginId.Add(plugin.PluginId, plugin);
 }
Beispiel #5
0
        /// <inheritdoc />
        public IPluginDescriptor RegisterPlugin(PluginRegistration pluginRegistration)
        {
            if (pluginRegistration == null)
                throw new ArgumentNullException("pluginRegistration");
            if (pluginRegistration.AssemblyBindings.Contains(null))
                throw new ArgumentException("The assembly references must not contain a null reference.", "pluginRegistration");
            if (pluginRegistration.PluginDependencies.Contains(null))
                throw new ArgumentException("The plugin dependencies must not contain a null reference.", "pluginRegistration");
            if (pluginRegistration.ProbingPaths.Contains(null))
                throw new ArgumentException("The probing paths must not contain a null reference.", "pluginRegistration");

            return dataBox.Write(data =>
            {
                if (data.GetPluginById(pluginRegistration.PluginId) != null)
                    throw new ArgumentException(string.Format("There is already a plugin registered with id '{0}'.", pluginRegistration.PluginId), "pluginRegistration");

                List<IPluginDescriptor> pluginDependencies = new List<IPluginDescriptor>(pluginRegistration.PluginDependencies);

                foreach (IPluginDescriptor pluginDependency in pluginRegistration.PluginDependencies)
                {
                    if (data.GetPluginById(pluginDependency.PluginId) != pluginDependency)
                        throw new ArgumentException(
                            "One of the plugin dependencies does not belong to this registry.", "pluginRegistration");

                    foreach (IPluginDescriptor secondOrderPluginDependency in pluginDependency.PluginDependencies)
                    {
                        if (!pluginDependencies.Contains(secondOrderPluginDependency))
                            pluginDependencies.Add(secondOrderPluginDependency);
                    }
                }

                PluginDescriptor plugin = new PluginDescriptor(this, pluginRegistration, pluginDependencies);
                data.RegisterPlugin(plugin);
                return plugin;
            });
        }