Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Core/3.2/PluginCache.cs @ 1530

Last change on this file since 1530 was 1530, checked in by gkronber, 15 years ago

Moved source files of plugins Hive ... Visualization.Test into version-specific sub-folders. #576

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.PluginInfrastructure;
6using HeuristicLab.Hive.Client.Communication;
7using HeuristicLab.Hive.Client.Common;
8
9namespace HeuristicLab.Hive.Client.Core {
10  public class PluginCache {
11    private List<CachedPlugin> pluginCache;
12   
13    public PluginCache() {
14      pluginCache = new List<CachedPlugin>();
15    }
16   
17    public void AddPlugin(CachedPlugin plugin) {
18      pluginCache.Add(plugin);   
19    }
20
21    public List<CachedPlugin> GetPlugins(List<PluginInfo> requests) {
22      List<CachedPlugin> neededPlugins = new List<CachedPlugin>();
23      List<PluginInfo> missingPlugins = new List<PluginInfo>();
24      bool found = false;
25      foreach (PluginInfo info in requests) {
26        foreach (CachedPlugin cache in pluginCache) {
27          if (info.Equals(cache)) {
28            neededPlugins.Add(cache);
29            found = true;
30            break;
31          }
32        }
33        if (!found)
34          missingPlugins.Add(info);
35        found = false;
36      }
37
38      List<CachedPlugin> receivedPlugins = WcfService.Instance.RequestPlugins(missingPlugins);
39      if (receivedPlugins != null) {
40        neededPlugins.AddRange(receivedPlugins);
41        pluginCache.AddRange(receivedPlugins);
42      } else
43        Logging.Instance.Error(this.ToString(), "Fetching of the plugins failed!");
44
45      return neededPlugins;
46    }
47
48  }
49}
Note: See TracBrowser for help on using the repository browser.