Changeset 3057
- Timestamp:
- 03/16/10 10:21:41 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj
r2951 r3057 30 30 <ErrorReport>prompt</ErrorReport> 31 31 <WarningLevel>4</WarningLevel> 32 <TreatWarningsAsErrors>true</TreatWarningsAsErrors> 32 33 </PropertyGroup> 33 34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/StorableAttributeTests.cs
r3025 r3057 12 12 13 13 [Storable(Name = "TestProperty", DefaultValue = 12)] 14 public object o ;14 public object o = null; 15 15 16 16 [Storable] 17 17 public int x = 2; 18 18 19 public int y; 20 19 public int y = 0; 21 20 } 22 21 -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3029 r3057 41 41 [Storable] 42 42 private ulong _ulong = 123456; 43 public override bool Equals(object obj) { 44 NumberTest nt = obj as NumberTest; 45 if (nt == null) 46 throw new NotSupportedException(); 47 return 48 nt._bool == _bool && 49 nt._byte == _byte && 50 nt._sbyte == _sbyte && 51 nt._short == _short && 52 nt._ushort == _ushort && 53 nt._int == _int && 54 nt._uint == _uint && 55 nt._long == _long && 56 nt._ulong == _ulong; 57 } 58 public override int GetHashCode() { 59 return 60 _bool.GetHashCode() ^ 61 _byte.GetHashCode() ^ 62 _sbyte.GetHashCode() ^ 63 _short.GetHashCode() ^ 64 _short.GetHashCode() ^ 65 _int.GetHashCode() ^ 66 _uint.GetHashCode() ^ 67 _long.GetHashCode() ^ 68 _ulong.GetHashCode(); 69 } 43 70 } 44 71 … … 86 113 [Storable] 87 114 private object o = new object(); 115 public override bool Equals(object obj) { 116 PrimitivesTest pt = obj as PrimitivesTest; 117 if (pt == null) 118 throw new NotSupportedException(); 119 return base.Equals(obj) && 120 c == pt.c && 121 _long_array == pt._long_array && 122 list == pt.list && 123 o == pt.o; 124 } 125 public override int GetHashCode() { 126 return base.GetHashCode() ^ 127 c.GetHashCode() ^ 128 _long_array.GetHashCode() ^ 129 list.GetHashCode() ^ 130 o.GetHashCode(); 131 } 88 132 } 89 133 … … 96 140 [Storable] 97 141 public TestEnum myEnum = TestEnum.va3; 142 public override bool Equals(object obj) { 143 RootBase rb = obj as RootBase; 144 if (rb == null) 145 throw new NotSupportedException(); 146 return baseString == rb.baseString && 147 myEnum == rb.myEnum; 148 } 149 public override int GetHashCode() { 150 return baseString.GetHashCode() ^ 151 myEnum.GetHashCode(); 152 } 98 153 } 99 154 … … 175 230 176 231 public class NonSerializable { 177 int x; 232 int x = 0; 233 public override bool Equals(object obj) { 234 NonSerializable ns = obj as NonSerializable; 235 if (ns == null) 236 throw new NotSupportedException(); 237 return ns.x == x; 238 } 239 public override int GetHashCode() { 240 return x.GetHashCode(); 241 } 178 242 } 179 243 … … 377 441 [Storable] 378 442 private string value = "value"; 443 public override bool Equals(object obj) { 444 NestedType nt = obj as NestedType; 445 if (nt == null) 446 throw new NotSupportedException(); 447 return nt.value == value; 448 } 449 public override int GetHashCode() { 450 return value.GetHashCode(); 451 } 379 452 } 380 453 … … 387 460 DebugStringGenerator.Serialize(t), 388 461 DebugStringGenerator.Serialize(o)); 462 Assert.IsTrue(t.Equals(o)); 389 463 } 390 464 … … 465 539 DebugStringGenerator.Serialize(sdt), 466 540 DebugStringGenerator.Serialize(o)); 541 Assert.IsTrue(sdt.Equals(o)); 467 542 } 468 543 -
trunk/sources/HeuristicLab.Tracing/3.2/Logger.cs
r2790 r3057 29 29 namespace HeuristicLab.Tracing { 30 30 31 /// <summary> 32 /// HeuristicLab Tracing entry point. Default logger. Reads configured tracing 33 /// file and provides automatic logging with reflection of the calling type. 34 /// </summary> 31 35 public class Logger { 32 36 37 /// <summary> 38 /// true if Configure has been called already. 39 /// </summary> 33 40 protected static bool IsConfigured = false; 34 41 42 /// <summary> 43 /// Configures this instance: Reads the log file specified in the settings. 44 /// </summary> 35 45 protected static void Configure() { 36 46 if (IsConfigured) return; … … 45 55 } 46 56 57 /// <summary> 58 /// Gets the default logger for the calling class n levels up in the 59 /// call hierarchy. 60 /// </summary> 61 /// <param name="nParents">The number of parent calls.</param> 62 /// <returns>An <see cref="ILog"/> instance.</returns> 47 63 public static ILog GetDefaultLogger(int nParents) { 48 64 Configure(); … … 51 67 } 52 68 69 /// <summary> 70 /// Gets the default logger: The logger for the class of the 71 /// calling method. 72 /// </summary> 73 /// <returns>An <see cref="ILog"/> instance.</returns> 53 74 public static ILog GetDefaultLogger() { 54 75 Configure(); … … 57 78 } 58 79 80 /// <summary> 81 /// Issues a debug message to the default logger. 82 /// </summary> 83 /// <param name="message">The message.</param> 59 84 public static void Debug(object message) { 60 85 GetDefaultLogger(1).Debug(message); 61 86 } 62 87 88 /// <summary> 89 /// Issues an informational message to the default logger. 90 /// </summary> 91 /// <param name="message">The message.</param> 63 92 public static void Info(object message) { 64 93 GetDefaultLogger(1).Info(message); 65 94 } 66 95 96 /// <summary> 97 /// Issues a warning message to the default logger. 98 /// </summary> 99 /// <param name="message">The message.</param> 67 100 public static void Warn(object message) { 68 101 GetDefaultLogger(1).Warn(message); 69 102 } 70 103 104 /// <summary> 105 /// Issues an error message to the default logger. 106 /// </summary> 107 /// <param name="message">The message.</param> 71 108 public static void Error(object message) { 72 109 GetDefaultLogger(1).Error(message); 73 110 } 74 111 112 /// <summary> 113 /// Issues a fatal error message to the default logger. 114 /// </summary> 115 /// <param name="message">The message.</param> 75 116 public static void Fatal(object message) { 76 117 GetDefaultLogger(1).Fatal(message); 77 118 } 78 119 120 /// <summary> 121 /// Issues a debug message to the logger of the specified type. 122 /// </summary> 123 /// <param name="type">The type.</param> 124 /// <param name="message">The message.</param> 79 125 public static void Debug(Type type, object message) { 80 126 Configure(); … … 82 128 } 83 129 130 /// <summary> 131 /// Issues an iformational message to the logger of the specified 132 /// type. 133 /// </summary> 134 /// <param name="type">The type.</param> 135 /// <param name="message">The message.</param> 84 136 public static void Info(Type type, object message) { 85 137 Configure(); … … 87 139 } 88 140 141 /// <summary> 142 /// Issues a warning message to the logger of 143 /// the specified type. 144 /// </summary> 145 /// <param name="type">The type.</param> 146 /// <param name="message">The message.</param> 89 147 public static void Warn(Type type, object message) { 90 148 Configure(); … … 92 150 } 93 151 152 /// <summary> 153 /// Issues an error message to the logger of the specified 154 /// type. 155 /// </summary> 156 /// <param name="type">The type.</param> 157 /// <param name="message">The message.</param> 94 158 public static void Error(Type type, object message) { 95 159 Configure(); … … 97 161 } 98 162 163 /// <summary> 164 /// Issues a fatal error message to the logger of 165 /// the specified type. 166 /// </summary> 167 /// <param name="type">The type.</param> 168 /// <param name="message">The message.</param> 99 169 public static void Fatal(Type type, object message) { 100 170 Configure(); … … 102 172 } 103 173 174 /// <summary> 175 /// Issues a debug message to the default 176 /// logger including an exception. 177 /// </summary> 178 /// <param name="message">The message.</param> 179 /// <param name="exception">The exception.</param> 104 180 public static void Debug(object message, Exception exception) { 105 181 GetDefaultLogger(1).Debug(message, exception); 106 182 } 107 183 184 /// <summary> 185 /// Issues an informational message to the default 186 /// logger including an exception. 187 /// </summary> 188 /// <param name="message">The message.</param> 189 /// <param name="exception">The exception.</param> 190 108 191 public static void Info(object message, Exception exception) { 109 192 GetDefaultLogger(1).Info(message, exception); 110 193 } 111 194 195 /// <summary> 196 /// Issues a warning message to the default 197 /// logger including an exception. 198 /// </summary> 199 /// <param name="message">The message.</param> 200 /// <param name="exception">The exception.</param> 112 201 public static void Warn(object message, Exception exception) { 113 202 GetDefaultLogger(1).Warn(message, exception); 114 203 } 115 204 205 /// <summary> 206 /// Issues an error message to the default 207 /// logger including an exception. 208 /// </summary> 209 /// <param name="message">The message.</param> 210 /// <param name="exception">The exception.</param> 116 211 public static void Error(object message, Exception exception) { 117 212 GetDefaultLogger(1).Error(message, exception); 118 213 } 119 214 215 /// <summary> 216 /// Issues a fatal error message to the default 217 /// logger including an exception. 218 /// </summary> 219 /// <param name="message">The message.</param> 220 /// <param name="exception">The exception.</param> 120 221 public static void Fatal(object message, Exception exception) { 121 222 GetDefaultLogger(1).Fatal(message, exception); 122 223 } 123 224 225 /// <summary> 226 /// Issues a debug message to the logger of the specified 227 /// type including an exception. 228 /// </summary> 229 /// <param name="type">The type.</param> 230 /// <param name="message">The message.</param> 231 /// <param name="exception">The exception.</param> 124 232 public static void Debug(Type type, object message, Exception exception) { 125 233 Configure(); … … 127 235 } 128 236 237 /// <summary> 238 /// Issues an informational message to the logger of the specified 239 /// type including an exception. 240 /// </summary> 241 /// <param name="type">The type.</param> 242 /// <param name="message">The message.</param> 243 /// <param name="exception">The exception.</param> 129 244 public static void Info(Type type, object message, Exception exception) { 130 245 Configure(); … … 132 247 } 133 248 249 /// <summary> 250 /// Issues a warning message to the logger of the specified 251 /// type including an exception. 252 /// </summary> 253 /// <param name="type">The type.</param> 254 /// <param name="message">The message.</param> 255 /// <param name="exception">The exception.</param> 134 256 public static void Warn(Type type, object message, Exception exception) { 135 257 Configure(); … … 137 259 } 138 260 261 /// <summary> 262 /// Issues an error message to the logger of the specified 263 /// type including an exception. 264 /// </summary> 265 /// <param name="type">The type.</param> 266 /// <param name="message">The message.</param> 267 /// <param name="exception">The exception.</param> 139 268 public static void Error(Type type, object message, Exception exception) { 140 269 Configure(); … … 142 271 } 143 272 273 /// <summary> 274 /// Issues a fatal error message to the logger of the specified 275 /// type including an exception. 276 /// </summary> 277 /// <param name="type">The type.</param> 278 /// <param name="message">The message.</param> 279 /// <param name="exception">The exception.</param> 144 280 public static void Fatal(Type type, object message, Exception exception) { 145 281 Configure(); 146 282 LogManager.GetLogger(type).Fatal(message, exception); 147 283 } 148 149 284 } 150 285 }
Note: See TracChangeset
for help on using the changeset viewer.