Changeset 16373 for branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data
- Timestamp:
- 12/12/18 14:23:45 (6 years ago)
- Location:
- branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r16070 r16373 124 124 <Compile Include="ComparisonType.cs" /> 125 125 <Compile Include="EnumValue.cs" /> 126 <Compile Include="Interfaces\ITextValue.cs" /> 126 127 <Compile Include="Interfaces\IValueTypeArray.cs" /> 127 128 <Compile Include="Path Types\DirectoryValue.cs" /> … … 151 152 <Compile Include="StringConvertibleArray.cs" /> 152 153 <Compile Include="StringMatrix.cs" /> 154 <Compile Include="TextValue.cs" /> 153 155 <Compile Include="StringValue.cs" /> 154 156 <Compile Include="TimeSpanValue.cs" /> -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Interfaces/ITextValue.cs
r16337 r16373 24 24 25 25 namespace HeuristicLab.Data { 26 public interface IStringConvertibleValue : IContent { 27 bool ReadOnly { get; } 28 29 bool Validate(string value, out string errorMessage); 30 string GetValue(); 31 bool SetValue(string value); 32 33 event EventHandler ValueChanged; 26 public interface ITextValue : IStringConvertibleValue { 34 27 } 35 28 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/TextValue.cs
r16337 r16373 20 20 #endregion 21 21 22 using System;23 using System.Drawing;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; … … 27 25 28 26 namespace HeuristicLab.Data { 29 [Item(" StringValue", "Represents astring.")]27 [Item("TextValue", "Represents a multiline string.")] 30 28 [StorableClass] 31 public class StringValue : Item, IComparable, IStringConvertibleValue { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.Field; } 29 public class TextValue : StringValue, ITextValue { 30 31 public TextValue() { 32 this.value = string.Empty; 33 this.readOnly = false; 34 34 } 35 35 36 [Storable] 37 protected string value; 38 public virtual string Value { 39 get { return value; } 40 set { 41 if (ReadOnly) throw new NotSupportedException("Value cannot be set. StringValue is read-only."); 42 if (value != this.value) { 43 if ((value != null) || (this.value != string.Empty)) { 44 this.value = value != null ? value : string.Empty; 45 OnValueChanged(); 46 } 47 } 48 } 49 } 50 51 [Storable] 52 protected bool readOnly; 53 public virtual bool ReadOnly { 54 get { return readOnly; } 36 public TextValue(string value) { 37 this.value = value ?? string.Empty; 38 this.readOnly = false; 55 39 } 56 40 57 41 [StorableConstructor] 58 protected StringValue(bool deserializing) : base(deserializing) { } 59 protected StringValue(StringValue original, Cloner cloner) 42 protected TextValue(bool deserializing) : base(deserializing) { } 43 44 protected TextValue(TextValue original, Cloner cloner) 60 45 : base(original, cloner) { 61 this.value = original.value != null ? original.value :string.Empty;46 this.value = original.value ?? string.Empty; 62 47 this.readOnly = original.readOnly; 63 }64 public StringValue() {65 this.value = string.Empty;66 this.readOnly = false;67 }68 public StringValue(string value) {69 this.value = value != null ? value : string.Empty;70 this.readOnly = false;71 48 } 72 49 73 50 public override IDeepCloneable Clone(Cloner cloner) { 74 return new StringValue(this, cloner);51 return new TextValue(this, cloner); 75 52 } 76 77 public virtual StringValue AsReadOnly() {78 StringValue readOnlyStringValue = (StringValue)this.Clone();79 readOnlyStringValue.readOnly = true;80 return readOnlyStringValue;81 }82 83 public override string ToString() {84 return value;85 }86 87 public virtual int CompareTo(object obj) {88 StringValue other = obj as StringValue;89 if (other != null)90 return Value.CompareTo(other.Value);91 else92 return Value.CompareTo(obj);93 }94 95 public event EventHandler ValueChanged;96 protected virtual void OnValueChanged() {97 if (ValueChanged != null)98 ValueChanged(this, EventArgs.Empty);99 OnToStringChanged();100 }101 102 protected virtual bool Validate(string value, out string errorMessage) {103 if (value == null) {104 errorMessage = "Invalid Value (string must not be null)";105 return false;106 } else {107 errorMessage = string.Empty;108 return true;109 }110 }111 protected virtual string GetValue() {112 return Value;113 }114 protected virtual bool SetValue(string value) {115 if (value != null) {116 Value = value;117 return true;118 } else {119 return false;120 }121 }122 123 #region IStringConvertibleValue Members124 bool IStringConvertibleValue.Validate(string value, out string errorMessage) {125 return Validate(value, out errorMessage);126 }127 string IStringConvertibleValue.GetValue() {128 return GetValue();129 }130 bool IStringConvertibleValue.SetValue(string value) {131 return SetValue(value);132 }133 #endregion134 53 } 135 54 }
Note: See TracChangeset
for help on using the changeset viewer.