Beispiel #1
0
        private void OnPluginChanged(object sender, ExtensionNodeEventArgs args)
        {
            DynamicItemSource source = args.ExtensionObject as DynamicItemSource;

            switch (args.Change)
            {
            case ExtensionChange.Add:
                lock (universe_lock) {
                    dynamicUniverses[source] = new UniverseCollection();
                }
                source.ItemsAvailable   += OnItemsAvailable;
                source.ItemsUnavailable += OnItemsUnavailable;
                Log <UniverseManager> .Debug("Added new ItemSource: {0}", source.Name);

                break;

            case ExtensionChange.Remove:
                source.ItemsAvailable   -= OnItemsAvailable;
                source.ItemsUnavailable -= OnItemsUnavailable;
                lock (universe_lock) {
                    dynamicUniverses.Remove(source);
                }
                Log <UniverseManager> .Debug("Removed ItemSource: {0}", source.Name);

                break;
            }
        }
Beispiel #2
0
        private void OnItemsUnavailable(object sender, ItemsUnavailableEventArgs args)
        {
            DynamicItemSource source = sender as DynamicItemSource;

            if (source == null)
            {
                Log <UniverseManager> .Error("OnItemsUnavailable called from a non-DynamicItemSource.");

                return;
            }
            lock (universe_lock) {
                foreach (Item item in args.unavailableItems)
                {
                    dynamicUniverses[source].Remove(item.UniqueId);
                }
            }
        }
Beispiel #3
0
        private void OnItemsAvailable(object sender, ItemsAvailableEventArgs args)
        {
            DynamicItemSource source = sender as DynamicItemSource;

            if (source == null)
            {
                Log <UniverseManager> .Error("OnItemsAvailable called from a non-DynamicItemSource.");

                return;
            }
            lock (universe_lock) {
                foreach (Item item in args.newItems)
                {
                    try {
                        dynamicUniverses[source].Add(item.UniqueId, item);
                    } catch (ArgumentException) {
                        Log <UniverseManager> .Error("DynamicItemSource {0} attmpted to add duplicate Item {1}", source.Name, item.UniqueId);
                    }
                }
            }
        }