Пример #1
0
 /// <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);
 }
Пример #2
0
 /// <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);
         }
 }
Пример #3
0
 public void Continue(PluginItemRegistration itemRegistration)
 {
 }
Пример #4
0
 public void Stop(PluginItemRegistration itemRegistration)
 {
   Uninstall();
 }
Пример #5
0
 public bool RequestEnd(PluginItemRegistration itemRegistration)
 {
   return true;
 }
Пример #6
0
 protected void RemoveLanguageResource(PluginItemRegistration itemRegistration)
 {
   PluginResource languageResource = (PluginResource) itemRegistration.Item;
   lock (_syncObj)
     _languageDirectories.Remove(languageResource.Path);
   ReLoad();
 }
Пример #7
0
 /// <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;
 }