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