@@ -148,18 +148,7 @@ internal AzureDevOpsWorkItem(
148
148
/// </summary>
149
149
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
150
150
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
151
- public int WorkItemId
152
- {
153
- get
154
- {
155
- if ( ! this . ValidateWorkItem ( ) )
156
- {
157
- return 0 ;
158
- }
159
-
160
- return this . workItem . Id ?? 0 ;
161
- }
162
- }
151
+ public int WorkItemId => this . ValidateWorkItem ( ) ? this . workItem . Id ?? 0 : 0 ;
163
152
164
153
/// <summary>
165
154
/// Gets the title of the work item.
@@ -168,18 +157,7 @@ public int WorkItemId
168
157
/// </summary>
169
158
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
170
159
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
171
- public string Title
172
- {
173
- get
174
- {
175
- if ( ! this . ValidateWorkItem ( ) )
176
- {
177
- return string . Empty ;
178
- }
179
-
180
- return this . GetField ( "System.Title" ) ;
181
- }
182
- }
160
+ public string Title => this . ValidateWorkItem ( ) ? this . GetField ( "System.Title" ) : string . Empty ;
183
161
184
162
/// <summary>
185
163
/// Gets the description of the work item.
@@ -188,18 +166,7 @@ public string Title
188
166
/// </summary>
189
167
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
190
168
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
191
- public string Description
192
- {
193
- get
194
- {
195
- if ( ! this . ValidateWorkItem ( ) )
196
- {
197
- return string . Empty ;
198
- }
199
-
200
- return this . GetField ( "System.Description" ) ;
201
- }
202
- }
169
+ public string Description => this . ValidateWorkItem ( ) ? this . GetField ( "System.Description" ) : string . Empty ;
203
170
204
171
/// <summary>
205
172
/// Gets the area path of the work item.
@@ -208,18 +175,7 @@ public string Description
208
175
/// </summary>
209
176
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
210
177
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
211
- public string AreaPath
212
- {
213
- get
214
- {
215
- if ( ! this . ValidateWorkItem ( ) )
216
- {
217
- return string . Empty ;
218
- }
219
-
220
- return this . GetField ( "System.AreaPath" ) ;
221
- }
222
- }
178
+ public string AreaPath => this . ValidateWorkItem ( ) ? this . GetField ( "System.AreaPath" ) : string . Empty ;
223
179
224
180
/// <summary>
225
181
/// Gets the team project name of the work item.
@@ -228,18 +184,7 @@ public string AreaPath
228
184
/// </summary>
229
185
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
230
186
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
231
- public string TeamProject
232
- {
233
- get
234
- {
235
- if ( ! this . ValidateWorkItem ( ) )
236
- {
237
- return string . Empty ;
238
- }
239
-
240
- return this . GetField ( "System.TeamProject" ) ;
241
- }
242
- }
187
+ public string TeamProject => this . ValidateWorkItem ( ) ? this . GetField ( "System.TeamProject" ) : string . Empty ;
243
188
244
189
/// <summary>
245
190
/// Gets the iteration path of the work item.
@@ -248,18 +193,7 @@ public string TeamProject
248
193
/// </summary>
249
194
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
250
195
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
251
- public string IterationPath
252
- {
253
- get
254
- {
255
- if ( ! this . ValidateWorkItem ( ) )
256
- {
257
- return string . Empty ;
258
- }
259
-
260
- return this . GetField ( "System.IterationPath" ) ;
261
- }
262
- }
196
+ public string IterationPath => this . ValidateWorkItem ( ) ? this . GetField ( "System.IterationPath" ) : string . Empty ;
263
197
264
198
/// <summary>
265
199
/// Gets the type of the work item.
@@ -268,18 +202,7 @@ public string IterationPath
268
202
/// </summary>
269
203
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
270
204
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
271
- public string WorkItemType
272
- {
273
- get
274
- {
275
- if ( ! this . ValidateWorkItem ( ) )
276
- {
277
- return string . Empty ;
278
- }
279
-
280
- return this . GetField ( "System.WorkItemType" ) ;
281
- }
282
- }
205
+ public string WorkItemType => this . ValidateWorkItem ( ) ? this . GetField ( "System.WorkItemType" ) : string . Empty ;
283
206
284
207
/// <summary>
285
208
/// Gets the state of the work item.
@@ -288,18 +211,7 @@ public string WorkItemType
288
211
/// </summary>
289
212
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
290
213
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
291
- public string State
292
- {
293
- get
294
- {
295
- if ( ! this . ValidateWorkItem ( ) )
296
- {
297
- return string . Empty ;
298
- }
299
-
300
- return this . GetField ( "System.State" ) ;
301
- }
302
- }
214
+ public string State => this . ValidateWorkItem ( ) ? this . GetField ( "System.State" ) : string . Empty ;
303
215
304
216
/// <summary>
305
217
/// Gets the reason of the state of the work item.
@@ -308,18 +220,7 @@ public string State
308
220
/// </summary>
309
221
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
310
222
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
311
- public string Reason
312
- {
313
- get
314
- {
315
- if ( ! this . ValidateWorkItem ( ) )
316
- {
317
- return string . Empty ;
318
- }
319
-
320
- return this . GetField ( "System.Reason" ) ;
321
- }
322
- }
223
+ public string Reason => this . ValidateWorkItem ( ) ? this . GetField ( "System.Reason" ) : string . Empty ;
323
224
324
225
/// <summary>
325
226
/// Gets the create date of the work item.
@@ -328,18 +229,7 @@ public string Reason
328
229
/// </summary>
329
230
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
330
231
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
331
- public DateTime CreateDate
332
- {
333
- get
334
- {
335
- if ( ! this . ValidateWorkItem ( ) )
336
- {
337
- return DateTime . MinValue ;
338
- }
339
-
340
- return this . GetFieldAsDate ( "System.CreatedDate" ) ;
341
- }
342
- }
232
+ public DateTime CreateDate => this . ValidateWorkItem ( ) ? this . GetFieldAsDate ( "System.CreatedDate" ) : DateTime . MinValue ;
343
233
344
234
/// <summary>
345
235
/// Gets the modify date of the work item.
@@ -348,18 +238,7 @@ public DateTime CreateDate
348
238
/// </summary>
349
239
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
350
240
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
351
- public DateTime ChangeDate
352
- {
353
- get
354
- {
355
- if ( ! this . ValidateWorkItem ( ) )
356
- {
357
- return DateTime . MinValue ;
358
- }
359
-
360
- return this . GetFieldAsDate ( "System.ChangedDate" ) ;
361
- }
362
- }
241
+ public DateTime ChangeDate => this . ValidateWorkItem ( ) ? this . GetFieldAsDate ( "System.ChangedDate" ) : DateTime . MinValue ;
363
242
364
243
/// <summary>
365
244
/// Gets the tags of the work item.
@@ -368,18 +247,9 @@ public DateTime ChangeDate
368
247
/// </summary>
369
248
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
370
249
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
371
- public IEnumerable < string > Tags
372
- {
373
- get
374
- {
375
- if ( ! this . ValidateWorkItem ( ) )
376
- {
377
- return Array . Empty < string > ( ) ;
378
- }
379
-
380
- return this . GetField ( "System.Tags" ) . Split ( "; " , StringSplitOptions . RemoveEmptyEntries ) ;
381
- }
382
- }
250
+ public IEnumerable < string > Tags => this . ValidateWorkItem ( )
251
+ ? ( IEnumerable < string > ) this . GetField ( "System.Tags" ) . Split ( "; " , StringSplitOptions . RemoveEmptyEntries )
252
+ : Array . Empty < string > ( ) ;
383
253
384
254
/// <summary>
385
255
/// Gets the id of the parent work item.
@@ -388,18 +258,7 @@ public IEnumerable<string> Tags
388
258
/// </summary>
389
259
/// <exception cref="AzureDevOpsWorkItemNotFoundException">If work item could not be found and
390
260
/// <see cref="AzureDevOpsWorkItemSettings.ThrowExceptionIfWorkItemCouldNotBeFound"/> is set to <c>true</c>.</exception>
391
- public int ParentWorkItemId
392
- {
393
- get
394
- {
395
- if ( ! this . ValidateWorkItem ( ) )
396
- {
397
- return 0 ;
398
- }
399
-
400
- return this . GetFieldAsInt ( "System.Parent" ) ;
401
- }
402
- }
261
+ public int ParentWorkItemId => this . ValidateWorkItem ( ) ? this . GetFieldAsInt ( "System.Parent" ) : 0 ;
403
262
404
263
/// <summary>
405
264
/// Gets the parent work item or null of no parent exists.
@@ -445,38 +304,17 @@ private bool ValidateWorkItem()
445
304
446
305
private string GetField ( string fieldName )
447
306
{
448
- if ( this . workItem . Fields . TryGetValue ( fieldName , out var field ) )
449
- {
450
- return field . ToString ( ) ;
451
- }
452
- else
453
- {
454
- return string . Empty ;
455
- }
307
+ return this . workItem . Fields . TryGetValue ( fieldName , out var field ) ? field . ToString ( ) : string . Empty ;
456
308
}
457
309
458
310
private DateTime GetFieldAsDate ( string fieldName )
459
311
{
460
- if ( this . workItem . Fields . TryGetValue ( fieldName , out var field ) )
461
- {
462
- return ( DateTime ) field ;
463
- }
464
- else
465
- {
466
- return DateTime . MinValue ;
467
- }
312
+ return this . workItem . Fields . TryGetValue ( fieldName , out var field ) ? ( DateTime ) field : DateTime . MinValue ;
468
313
}
469
314
470
315
private int GetFieldAsInt ( string fieldName )
471
316
{
472
- if ( this . workItem . Fields . TryGetValue ( fieldName , out var field ) )
473
- {
474
- return Convert . ToInt32 ( field ) ;
475
- }
476
- else
477
- {
478
- return 0 ;
479
- }
317
+ return this . workItem . Fields . TryGetValue ( fieldName , out var field ) ? Convert . ToInt32 ( field ) : 0 ;
480
318
}
481
319
}
482
- }
320
+ }
0 commit comments