Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Console/AgentList.cs @ 357

Last change on this file since 357 was 357, checked in by gkronber, 16 years ago

worked on ticket #187. code is a mess. work-in-progress.

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using System.Collections;
7using HeuristicLab.CEDMA.DB.Interfaces;
8
9namespace HeuristicLab.CEDMA.Console {
10  public class AgentList: ItemBase, IAgentList {
11    private string serverUri;
12    private List<IAgent> agentList;
13    private IDatabase database;
14    public IDatabase Database {
15      get { return database; }
16      set {
17        database = value;
18        ReloadList();
19      }
20    }
21
22    private void ReloadList() {
23      agentList.Clear();
24      foreach(HeuristicLab.CEDMA.DB.Interfaces.IAgent a in database.GetAgents()) {
25        Agent newAgent = new Agent();
26        newAgent.Name = a.Name;
27        agentList.Add(newAgent);
28      }
29      FireChanged();
30    }
31
32    public AgentList()
33      : base() {
34      agentList = new List<IAgent>();
35    }
36   
37    public void Add(IAgent agent) {
38      agentList.Add(agent);
39    }
40
41    public IEnumerator<IAgent> GetEnumerator() {
42      return agentList.GetEnumerator();
43    }
44
45    IEnumerator IEnumerable.GetEnumerator() {
46      return GetEnumerator();
47    }
48
49    public override IView CreateView() {
50      return new AgentListView(this);
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.