Ejemplo n.º 1
0
        /// <summary>
        /// Set an existing plugin's dependency to an existing service.
        /// </summary>
        /// <param name="plugin">Plugin</param>
        /// <param name="service">Service the plugin depends on</param>
        /// <param name="runningRequirement">How the plugin depends on the service</param>
        internal void SetPluginDependency(PluginInfo plugin, ServiceInfo service, DependencyRequirement runningRequirement)
        {
            Debug.Assert(plugin != null);
            Debug.Assert(service != null);
            Debug.Assert(ServiceInfos.Contains(service));
            Debug.Assert(PluginInfos.Contains(plugin));

            MockServiceReferenceInfo reference = new MockServiceReferenceInfo(plugin, service, runningRequirement);

            plugin.InternalServiceReferences.Add(reference);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes an existing plugin dependency.
        /// </summary>
        /// <param name="plugin">Plugin owner.</param>
        /// <param name="service">Service reference</param>
        internal void RemovePluginDependency(PluginInfo plugin, ServiceInfo service)
        {
            Debug.Assert(plugin != null);
            Debug.Assert(service != null);
            Debug.Assert(ServiceInfos.Contains(service));
            Debug.Assert(PluginInfos.Contains(plugin));

            MockServiceReferenceInfo reference = plugin.InternalServiceReferences.First(x => x.Reference == service);

            if (reference != null)
            {
                plugin.InternalServiceReferences.Remove(reference);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new named plugin, which implements an existing service.
        /// </summary>
        /// <param name="pluginName">Name of the new plugin</param>
        /// <param name="service">Implemented service</param>
        /// <returns>New plugin</returns>
        internal PluginInfo CreateNewPlugin(string pluginName, ServiceInfo service = null)
        {
            Debug.Assert(!String.IsNullOrWhiteSpace(pluginName));

            if (service != null)
            {
                Debug.Assert(ServiceInfos.Contains(service));
            }

            PluginInfo plugin = new PluginInfo(pluginName, AssemblyInfoHelper.ExecutingAssemblyInfo, service);

            CreateLabPlugin(plugin);
            _pluginInfos.Add(plugin);   // Throws on duplicate

            return(plugin);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new named service, which specializes another service.
        /// </summary>
        /// <param name="serviceName">Name of the new service</param>
        /// <param name="generalization">Specialized service</param>
        /// <returns>New service</returns>
        /// <remarks>Cannot be used when engine is running.</remarks>
        internal ServiceInfo CreateNewService(string serviceName, ServiceInfo generalization = null)
        {
            Debug.Assert(serviceName != null);
            Debug.Assert(_serviceInfos.Any(x => x.ServiceFullName == serviceName) == false, "Service does not exist and can be added");

            if (generalization != null)
            {
                Debug.Assert(ServiceInfos.Contains(generalization));
            }

            ServiceInfo newService = new ServiceInfo(serviceName, AssemblyInfoHelper.ExecutingAssemblyInfo, generalization);

            CreateLabService(newService);
            _serviceInfos.Add(newService);   // Throws on duplicate


            return(newService);
        }