Changeset 9401 for branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/ValueTypeArray.cs
- Timestamp:
- 04/29/13 11:36:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/ValueTypeArray.cs
r9308 r9401 42 42 43 43 [Storable] 44 protected List<string> columnNames;45 public virtual IEnumerable<string> ColumnNames {46 get { return this. columnNames; }44 protected List<string> elementNames; 45 public virtual IEnumerable<string> ElementNames { 46 get { return this.elementNames; } 47 47 set { 48 if (ReadOnly) throw new NotSupportedException(" ColumnNames cannot be set. ValueTypeArray is read-only.");48 if (ReadOnly) throw new NotSupportedException("ElementNames cannot be set. ValueTypeArray is read-only."); 49 49 if (value == null || value.Count() == 0) 50 columnNames = new List<string>();50 elementNames = new List<string>(); 51 51 else if (value.Count() != Length) 52 throw new ArgumentException("A column name must be specified for each column.");52 throw new ArgumentException("An element name must be specified for each element."); 53 53 else 54 columnNames = new List<string>(value);55 On ColumnNamesChanged();54 elementNames = new List<string>(value); 55 OnElementNamesChanged(); 56 56 } 57 57 } … … 65 65 if (value != Length) { 66 66 Array.Resize<T>(ref array, value); 67 while ( columnNames.Count > value)68 columnNames.RemoveAt(columnNames.Count - 1);69 while ( columnNames.Count < value)70 columnNames.Add("Column " + columnNames.Count);71 On ColumnNamesChanged();67 while (elementNames.Count > value) 68 elementNames.RemoveAt(elementNames.Count - 1); 69 while (elementNames.Count < value) 70 elementNames.Add("Element " + elementNames.Count); 71 OnElementNamesChanged(); 72 72 OnReset(); 73 73 } … … 106 106 [StorableHook(HookType.AfterDeserialization)] 107 107 private void AfterDeserialization() { 108 if ( columnNames == null) {109 columnNames = new List<string>(array.Length);110 while ( columnNames.Count < array.Length)111 columnNames.Add("Column " + columnNames.Count);108 if (elementNames == null) { 109 elementNames = new List<string>(array.Length); 110 while (elementNames.Count < array.Length) 111 elementNames.Add("Element " + elementNames.Count); 112 112 } 113 113 } … … 118 118 : base(original, cloner) { 119 119 this.array = (T[])original.array.Clone(); 120 this. columnNames = new List<string>(original.columnNames);120 this.elementNames = new List<string>(original.elementNames); 121 121 this.readOnly = original.readOnly; 122 122 } 123 123 protected ValueTypeArray() { 124 124 array = new T[0]; 125 columnNames = new List<string>();125 elementNames = new List<string>(); 126 126 readOnly = false; 127 127 } 128 128 protected ValueTypeArray(int length) { 129 129 array = new T[length]; 130 columnNames = new List<string>(length);130 elementNames = new List<string>(length); 131 131 readOnly = false; 132 132 } … … 134 134 if (elements == null) throw new ArgumentNullException(); 135 135 array = (T[])elements.Clone(); 136 columnNames = new List<string>(elements.Length);136 elementNames = new List<string>(elements.Length); 137 137 readOnly = false; 138 138 } … … 164 164 } 165 165 166 public event EventHandler ColumnNamesChanged;167 protected virtual void On ColumnNamesChanged() {168 EventHandler handler = ColumnNamesChanged;166 public event EventHandler ElementNamesChanged; 167 protected virtual void OnElementNamesChanged() { 168 EventHandler handler = ElementNamesChanged; 169 169 if (handler != null) 170 170 handler(this, EventArgs.Empty);
Note: See TracChangeset
for help on using the changeset viewer.