- Timestamp:
- 02/08/10 03:43:36 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/ExecutionContextCollection.cs
r2664 r2757 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Text; 25 26 using System.Xml; … … 27 28 28 29 namespace HeuristicLab.Core { 29 public class ExecutionContextCollection : DeepCloneable, IList< ExecutionContext>{30 public class ExecutionContextCollection : DeepCloneable, IList<IExecutionContext>, IExecutionContext { 30 31 [Storable] 31 private IList< ExecutionContext> contexts;32 private IList<IExecutionContext> contexts; 32 33 33 34 [Storable] … … 39 40 40 41 public ExecutionContextCollection() { 41 contexts = new List< ExecutionContext>();42 contexts = new List<IExecutionContext>(); 42 43 parallel = false; 43 44 } 44 public ExecutionContextCollection(IEnumerable< ExecutionContext> collection) {45 contexts = new List< ExecutionContext>(collection);45 public ExecutionContextCollection(IEnumerable<IExecutionContext> collection) { 46 contexts = new List<IExecutionContext>(collection.Where(e => e != null)); 46 47 parallel = false; 47 48 } 48 public ExecutionContextCollection(params ExecutionContext[] list) {49 contexts = new List< ExecutionContext>(list);49 public ExecutionContextCollection(params IExecutionContext[] list) { 50 contexts = new List<IExecutionContext>(list.Where(e => e != null)); 50 51 parallel = false; 51 52 } … … 56 57 clone.parallel = parallel; 57 58 for (int i = 0; i < contexts.Count; i++) 58 clone.contexts.Add(( ExecutionContext)cloner.Clone(contexts[i]));59 clone.contexts.Add((IExecutionContext)cloner.Clone(contexts[i])); 59 60 return clone; 60 61 } 61 62 62 #region IList< ExecutionContext> Members63 public int IndexOf( ExecutionContext item) {63 #region IList<IExecutionContext> Members 64 public int IndexOf(IExecutionContext item) { 64 65 return contexts.IndexOf(item); 65 66 } 66 public void Insert(int index, ExecutionContext item) {67 contexts.Insert(index, item);67 public void Insert(int index, IExecutionContext item) { 68 if (item != null) contexts.Insert(index, item); 68 69 } 69 70 public void RemoveAt(int index) { 70 71 contexts.RemoveAt(index); 71 72 } 72 public ExecutionContext this[int index] {73 public IExecutionContext this[int index] { 73 74 get { return contexts[index]; } 74 set { contexts[index] = value; }75 set { if (value != null) contexts[index] = value; } 75 76 } 76 77 #endregion 77 78 78 #region ICollection< ExecutionContext> Members79 public void Add( ExecutionContext item) {80 contexts.Add(item);79 #region ICollection<IExecutionContext> Members 80 public void Add(IExecutionContext item) { 81 if (item != null) contexts.Add(item); 81 82 } 82 83 public void Clear() { 83 84 contexts.Clear(); 84 85 } 85 public bool Contains( ExecutionContext item) {86 public bool Contains(IExecutionContext item) { 86 87 return contexts.Contains(item); 87 88 } 88 public void CopyTo( ExecutionContext[] array, int arrayIndex) {89 public void CopyTo(IExecutionContext[] array, int arrayIndex) { 89 90 contexts.CopyTo(array, arrayIndex); 90 91 } … … 95 96 get { return contexts.IsReadOnly; } 96 97 } 97 public bool Remove( ExecutionContext item) {98 public bool Remove(IExecutionContext item) { 98 99 return contexts.Remove(item); 99 100 } 100 101 #endregion 101 102 102 #region IEnumerable< ExecutionContext> Members103 public IEnumerator< ExecutionContext> GetEnumerator() {103 #region IEnumerable<IExecutionContext> Members 104 public IEnumerator<IExecutionContext> GetEnumerator() { 104 105 return contexts.GetEnumerator(); 105 106 }
Note: See TracChangeset
for help on using the changeset viewer.