Line | |
---|
1 | using System.Collections.Generic;
|
---|
2 | using System.Linq;
|
---|
3 |
|
---|
4 | namespace Common
|
---|
5 | {
|
---|
6 | public class NamedList
|
---|
7 | {
|
---|
8 | public string Name;
|
---|
9 | public List<string> List;
|
---|
10 | }
|
---|
11 |
|
---|
12 | public class NamedLists : List<NamedList>
|
---|
13 | {
|
---|
14 | public void Add(string name, string listItemName)
|
---|
15 | {
|
---|
16 | NamedList item = this.FirstOrDefault(x => x.Name == name);
|
---|
17 | if (item == null)
|
---|
18 | {
|
---|
19 | item = new NamedList { Name = name, List = new List<string>() };
|
---|
20 | Add(item);
|
---|
21 | }
|
---|
22 |
|
---|
23 | if (!item.List.Contains(listItemName))
|
---|
24 | {
|
---|
25 | item.List.Add(listItemName);
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | public NamedLists GetReverse()
|
---|
30 | {
|
---|
31 | NamedLists result = new NamedLists();
|
---|
32 | foreach (NamedList item in this)
|
---|
33 | {
|
---|
34 | foreach (string item2 in item.List)
|
---|
35 | {
|
---|
36 | result.Add(item2, item.Name);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | return result;
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.