/// <summary> /// Registers the specified plugin item in the plugin tree. /// </summary> /// <param name="itemMetadata">Metadata structure of the item to register.</param> /// <returns><c>true</c>, if the plugin item could be registered, <c>false</c>, /// if the item already existed and <see cref="PluginItemMetadata.IsRedundant"/> is specified.</returns> /// <exception cref="ArgumentException">If there is already an item registered at the registration /// location and the <see cref="PluginItemMetadata.IsRedundant"/> flag is not set.</exception> internal bool RegisterItem(PluginItemMetadata itemMetadata) { lock (_syncObj) { IRegistryNode node = GetRegistryNode(itemMetadata.RegistrationLocation, true); itemMetadata.PluginRuntime = this; if (node.Items != null && node.Items.ContainsKey(itemMetadata.Id)) { if (itemMetadata.IsRedundant) { PluginItemRegistration itemRegistration = (PluginItemRegistration)node.Items[itemMetadata.Id]; itemRegistration.AdditionalRedundantItemsMetadata.Add(itemMetadata); return(false); } else { throw new ArgumentException(string.Format("At location '{0}', a plugin item with id '{1}' is already registered", itemMetadata.RegistrationLocation, itemMetadata.Id)); } } PluginItemRegistration resultItemRegistration = new PluginItemRegistration(itemMetadata); node.AddItem(itemMetadata.Id, resultItemRegistration); _itemRegistrations.Add(itemMetadata, resultItemRegistration); } return(true); }
/// <summary> /// Unregisters the specified plugin item from the plugin tree. /// </summary> /// <param name="itemMetadata">Meta data structure of the item to unregister.</param> /// <returns>Plugin item registration structure of the item to be unregistered.</returns> internal void UnregisterItem(PluginItemMetadata itemMetadata) { lock (_syncObj) try { IRegistryNode node = GetRegistryNode(itemMetadata.RegistrationLocation, false); if (node == null || node.Items == null) { return; } if (node.Items.ContainsKey(itemMetadata.Id)) { PluginItemRegistration itemRegistration = (PluginItemRegistration)node.Items[itemMetadata.Id]; // Check, if there are additional redundant items registered at this position. If yes, we'll use // the first of them instead of the old item to be unregistered. PluginItemMetadata newItemMetadata = null; IEnumerator <PluginItemMetadata> enumerator = itemRegistration.AdditionalRedundantItemsMetadata.GetEnumerator(); if (enumerator.MoveNext()) { newItemMetadata = enumerator.Current; itemRegistration.AdditionalRedundantItemsMetadata.Remove(newItemMetadata); } node.Items.Remove(itemMetadata.Id); if (newItemMetadata != null) { newItemMetadata.PluginRuntime.RegisterItem(newItemMetadata); } } } finally { _itemRegistrations.Remove(itemMetadata); } }
public void Continue(PluginItemRegistration itemRegistration) { }
public void Stop(PluginItemRegistration itemRegistration) { Uninstall(); }
public bool RequestEnd(PluginItemRegistration itemRegistration) { return true; }
protected void RemoveLanguageResource(PluginItemRegistration itemRegistration) { PluginResource languageResource = (PluginResource) itemRegistration.Item; lock (_syncObj) _languageDirectories.Remove(languageResource.Path); ReLoad(); }
/// <summary> /// Registers the specified plugin item in the plugin tree. /// </summary> /// <param name="itemMetadata">Metadata structure of the item to register.</param> /// <returns><c>true</c>, if the plugin item could be registered, <c>false</c>, /// if the item already existed and <see cref="PluginItemMetadata.IsRedundant"/> is specified.</returns> /// <exception cref="ArgumentException">If there is already an item registered at the registration /// location and the <see cref="PluginItemMetadata.IsRedundant"/> flag is not set.</exception> internal bool RegisterItem(PluginItemMetadata itemMetadata) { lock (_syncObj) { IRegistryNode node = GetRegistryNode(itemMetadata.RegistrationLocation, true); itemMetadata.PluginRuntime = this; if (node.Items != null && node.Items.ContainsKey(itemMetadata.Id)) if (itemMetadata.IsRedundant) { PluginItemRegistration itemRegistration = (PluginItemRegistration) node.Items[itemMetadata.Id]; itemRegistration.AdditionalRedundantItemsMetadata.Add(itemMetadata); return false; } else throw new ArgumentException(string.Format("At location '{0}', a plugin item with id '{1}' is already registered", itemMetadata.RegistrationLocation, itemMetadata.Id)); PluginItemRegistration resultItemRegistration = new PluginItemRegistration(itemMetadata); node.AddItem(itemMetadata.Id, resultItemRegistration); _itemRegistrations.Add(itemMetadata, resultItemRegistration); } return true; }