|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Collections.Generic; |
|
19 |
|
20 namespace SymbianUtils.FileSystem.FilePair |
|
21 { |
|
22 public class FileNamePairCollection : IEnumerable<FileNamePair> |
|
23 { |
|
24 #region Constructor |
|
25 public FileNamePairCollection() |
|
26 { |
|
27 } |
|
28 #endregion |
|
29 |
|
30 #region API |
|
31 public void Clear() |
|
32 { |
|
33 iList.Clear(); |
|
34 } |
|
35 |
|
36 public void Add( IEnumerable<FileNamePair> aList ) |
|
37 { |
|
38 foreach ( FileNamePair entry in aList ) |
|
39 { |
|
40 Add( entry ); |
|
41 } |
|
42 } |
|
43 |
|
44 public void Add( FileNamePair aItem ) |
|
45 { |
|
46 iList.Add( aItem ); |
|
47 } |
|
48 |
|
49 public void RemoveAt( int aIndex ) |
|
50 { |
|
51 iList.RemoveAt( aIndex ); |
|
52 } |
|
53 |
|
54 public bool Contains( FileNamePair aItem ) |
|
55 { |
|
56 bool exists = false; |
|
57 // |
|
58 foreach ( FileNamePair entry in iList ) |
|
59 { |
|
60 if ( entry.Source.ToLower() == aItem.Source.ToLower() ) |
|
61 { |
|
62 exists = true; |
|
63 break; |
|
64 } |
|
65 else if ( entry.Destination.ToLower() == aItem.Destination.ToLower() ) |
|
66 { |
|
67 exists = true; |
|
68 break; |
|
69 } |
|
70 } |
|
71 // |
|
72 return exists; |
|
73 } |
|
74 #endregion |
|
75 |
|
76 #region Properties |
|
77 public int Count |
|
78 { |
|
79 get { return iList.Count; } |
|
80 } |
|
81 |
|
82 public FileNamePair this[ int aIndex ] |
|
83 { |
|
84 get |
|
85 { |
|
86 FileNamePair item = (FileNamePair) iList[ aIndex ]; |
|
87 return item; |
|
88 } |
|
89 } |
|
90 #endregion |
|
91 |
|
92 #region From IEnumerable |
|
93 IEnumerator<FileNamePair> IEnumerable<FileNamePair>.GetEnumerator() |
|
94 { |
|
95 foreach ( FileNamePair entry in iList ) |
|
96 { |
|
97 yield return entry; |
|
98 } |
|
99 } |
|
100 |
|
101 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
102 { |
|
103 foreach ( FileNamePair entry in iList ) |
|
104 { |
|
105 yield return entry; |
|
106 } |
|
107 } |
|
108 #endregion |
|
109 |
|
110 #region Data members |
|
111 private List<FileNamePair> iList = new List<FileNamePair>(); |
|
112 #endregion |
|
113 } |
|
114 } |