- Timestamp:
- 04/29/13 11:36:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ImprovingStringConvertibleMatrix/HeuristicLab.Data/3.3/StringArray.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 } … … 63 63 if (value != Length) { 64 64 Array.Resize<string>(ref array, value); 65 while ( columnNames.Count > value)66 columnNames.RemoveAt(columnNames.Count - 1);67 while ( columnNames.Count < value)68 columnNames.Add("Column " + columnNames.Count);69 On ColumnNamesChanged();65 while (elementNames.Count > value) 66 elementNames.RemoveAt(elementNames.Count - 1); 67 while (elementNames.Count < value) 68 elementNames.Add("Element " + elementNames.Count); 69 OnElementNamesChanged(); 70 70 OnReset(); 71 71 } … … 93 93 [StorableHook(HookType.AfterDeserialization)] 94 94 private void AfterDeserialization() { 95 if ( columnNames == null) {96 columnNames = new List<string>(array.Length);97 while ( columnNames.Count < array.Length)98 columnNames.Add("Column " + columnNames.Count);95 if (elementNames == null) { 96 elementNames = new List<string>(array.Length); 97 while (elementNames.Count < array.Length) 98 elementNames.Add("Element " + elementNames.Count); 99 99 } 100 100 } … … 105 105 : base(original, cloner) { 106 106 this.array = (string[])original.array.Clone(); 107 this. columnNames = new List<string>(original.columnNames);107 this.elementNames = new List<string>(original.elementNames); 108 108 this.readOnly = original.readOnly; 109 109 } 110 110 public StringArray() { 111 111 array = new string[0]; 112 columnNames = new List<string>();112 elementNames = new List<string>(); 113 113 readOnly = false; 114 114 } … … 117 117 for (int i = 0; i < array.Length; i++) 118 118 array[i] = string.Empty; 119 columnNames = new List<string>();119 elementNames = new List<string>(); 120 120 readOnly = false; 121 121 } … … 125 125 for (int i = 0; i < array.Length; i++) 126 126 array[i] = elements[i] == null ? string.Empty : elements[i]; 127 columnNames = new List<string>();127 elementNames = new List<string>(); 128 128 readOnly = false; 129 129 } … … 194 194 } 195 195 196 public event EventHandler ColumnNamesChanged;197 protected virtual void On ColumnNamesChanged() {198 EventHandler handler = ColumnNamesChanged;196 public event EventHandler ElementNamesChanged; 197 protected virtual void OnElementNamesChanged() { 198 EventHandler handler = ElementNamesChanged; 199 199 if (handler != null) 200 200 handler(this, EventArgs.Empty);
Note: See TracChangeset
for help on using the changeset viewer.