Changeset 10582 for branches/DataPreprocessing
- Timestamp:
- 03/12/14 16:01:49 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Filter/ComparisonFilter.cs
r10558 r10582 23 23 using HeuristicLab.Common.Resources; 24 24 using HeuristicLab.Core; 25 using System; 26 using System.Collections; 27 using HeuristicLab.Common; 28 using HeuristicLab.Data; 25 29 26 namespace HeuristicLab.DataPreprocessing.Filter { 27 [Item("ComparisonFilter", "Represents the comparison Filter.")] 28 public class ComparisonFilter : ComparisonConstraint, IFilter { 29 public override string ItemName { 30 get { return "ComparisonFilter"; } 30 namespace HeuristicLab.DataPreprocessing.Filter 31 { 32 [Item("ComparisonFilter", "Represents the comparison Filter.")] 33 public class ComparisonFilter : ComparisonConstraint, IFilter 34 { 35 36 37 protected ComparisonFilter(bool deserializing) : base(deserializing) { } 38 39 protected ComparisonFilter(ComparisonFilter original, Cloner cloner) 40 : base(original, cloner) 41 { 42 constraintColumn = original.constraintColumn; 43 } 44 public override IDeepCloneable Clone(Cloner cloner) 45 { 46 return new ComparisonFilter(this, cloner); 47 } 48 49 public ComparisonFilter() : base() { } 50 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData) 51 : base(constrainedValue, constraintOperation, constraintData) 52 { 53 } 54 55 public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active) 56 : base(constrainedValue, constraintOperation, constraintData, active) 57 { 58 } 59 60 61 public override string ItemName 62 { 63 get { return "ComparisonFilter"; } 64 } 65 66 public override Image ItemImage 67 { 68 get { return VSImageLibrary.Filter; } 69 } 70 71 public new IPreprocessingData ConstrainedValue 72 { 73 get { return (IPreprocessingData)base.ConstrainedValue; } 74 set { base.ConstrainedValue = value; } 75 } 76 77 public new IStringConvertibleValue ConstraintData 78 { 79 get { return (IStringConvertibleValue)base.ConstraintData; } 80 set 81 { 82 if (!(value is IComparable)) 83 throw new ArgumentException("Only IComparables allowed for ConstraintData"); 84 base.ConstraintData = value; 85 } 86 } 87 88 89 private int constraintColumn; 90 public int ConstraintColumn 91 { 92 get { return constraintColumn; } 93 set 94 { 95 if (ConstrainedValue.Columns < value) 96 throw new ArgumentException("Could not set ConstraintData to not existing column index."); 97 98 if (constraintColumn != value) 99 { 100 constraintColumn = value; 101 this.OnConstraintColumnChanged(); 102 this.OnToStringChanged(); 103 } 104 } 105 } 106 107 protected override bool Check(object constrainedMember) 108 { 109 if (!Active) 110 return false; 111 112 for (int row = 0; row < ConstrainedValue.Rows; ++row) 113 { 114 115 object item = null; 116 if (ConstrainedValue.IsType<double>(constraintColumn)) 117 { 118 item = ConstrainedValue.GetCell<double>(ConstraintColumn, row); 119 } 120 else if (ConstrainedValue.IsType<DateTime>(constraintColumn)) 121 { 122 item = ConstrainedValue.GetCell<DateTime>(ConstraintColumn, row); 123 } 124 else 125 { 126 item = ConstrainedValue.GetCell<string>(ConstraintColumn, row); 127 } 128 129 if (!base.Check(item)) 130 return true; 131 132 } 133 134 return false; 135 } 136 137 protected override bool Check(object constrainedMember, out string errorMessage) 138 { 139 errorMessage = string.Empty; 140 return this.Check(constrainedMember); 141 } 142 143 public event EventHandler ConstraintColumnChanged; 144 protected virtual void OnConstraintColumnChanged() 145 { 146 EventHandler handler = ConstraintColumnChanged; 147 if (handler != null) 148 handler(this, EventArgs.Empty); 149 } 31 150 } 32 33 public override Image ItemImage {34 get { return VSImageLibrary.Filter; }35 }36 }37 151 }
Note: See TracChangeset
for help on using the changeset viewer.