@@ -293,116 +293,6 @@ extension ProgressManager {
293
293
}
294
294
}
295
295
296
- /// Gets or sets the total file count property.
297
- /// - Parameter key: A key path to the `TotalFileCount` property type.
298
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . TotalFileCount . Type > ) -> Int {
299
- get {
300
- return state. totalFileCount
301
- }
302
-
303
- set {
304
-
305
- guard newValue != state. totalFileCount else {
306
- return
307
- }
308
-
309
- state. totalFileCount = newValue
310
-
311
- totalFileCountDirty = true
312
- }
313
- }
314
-
315
- /// Gets or sets the completed file count property.
316
- /// - Parameter key: A key path to the `CompletedFileCount` property type.
317
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . CompletedFileCount . Type > ) -> Int {
318
- get {
319
- return state. completedFileCount
320
- }
321
-
322
- set {
323
-
324
- guard newValue != state. completedFileCount else {
325
- return
326
- }
327
-
328
- state. completedFileCount = newValue
329
-
330
- completedFileCountDirty = true
331
- }
332
- }
333
-
334
- /// Gets or sets the total byte count property.
335
- /// - Parameter key: A key path to the `TotalByteCount` property type.
336
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . TotalByteCount . Type > ) -> UInt64 {
337
- get {
338
- return state. totalByteCount
339
- }
340
-
341
- set {
342
- guard newValue != state. totalByteCount else {
343
- return
344
- }
345
-
346
- state. totalByteCount = newValue
347
-
348
- totalByteCountDirty = true
349
- }
350
- }
351
-
352
- /// Gets or sets the completed byte count property.
353
- /// - Parameter key: A key path to the `CompletedByteCount` property type.
354
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . CompletedByteCount . Type > ) -> UInt64 {
355
- get {
356
- return state. completedByteCount
357
- }
358
-
359
- set {
360
- guard newValue != state. completedByteCount else {
361
- return
362
- }
363
-
364
- state. completedByteCount = newValue
365
-
366
- completedByteCountDirty = true
367
- }
368
- }
369
-
370
- /// Gets or sets the throughput property.
371
- /// - Parameter key: A key path to the `Throughput` property type.
372
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . Throughput . Type > ) -> UInt64 {
373
- get {
374
- return state. throughput
375
- }
376
-
377
- set {
378
- guard newValue != state. throughput else {
379
- return
380
- }
381
-
382
- state. throughput = newValue
383
-
384
- throughputDirty = true
385
- }
386
- }
387
-
388
- /// Gets or sets the estimated time remaining property.
389
- /// - Parameter key: A key path to the `EstimatedTimeRemaining` property type.
390
- public subscript( dynamicMember key: KeyPath < ProgressManager . Properties , ProgressManager . Properties . EstimatedTimeRemaining . Type > ) -> Duration {
391
- get {
392
- return state. estimatedTimeRemaining
393
- }
394
-
395
- set {
396
- guard newValue != state. estimatedTimeRemaining else {
397
- return
398
- }
399
-
400
- state. estimatedTimeRemaining = newValue
401
-
402
- estimatedTimeRemainingDirty = true
403
- }
404
- }
405
-
406
296
/// Gets or sets custom integer properties.
407
297
///
408
298
/// This subscript provides read-write access to custom progress properties where both the value
@@ -412,17 +302,42 @@ extension ProgressManager {
412
302
/// - Parameter key: A key path to the custom integer property type.
413
303
public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> Int where P. Value == Int , P. Summary == Int {
414
304
get {
415
- return state. propertiesInt [ MetatypeWrapper ( P . self) ] ?? P . defaultValue
305
+ if P . self == ProgressManager . Properties. TotalFileCount. self {
306
+ return state. totalFileCount
307
+ } else if P . self == ProgressManager . Properties. CompletedFileCount. self {
308
+ return state. completedFileCount
309
+ } else {
310
+ return state. propertiesInt [ MetatypeWrapper ( P . self) ] ?? P . defaultValue
311
+ }
416
312
}
417
313
418
314
set {
419
- guard newValue != state. propertiesInt [ MetatypeWrapper ( P . self) ] else {
420
- return
421
- }
422
-
423
- state. propertiesInt [ MetatypeWrapper ( P . self) ] = newValue
315
+ if P . self == ProgressManager . Properties. TotalFileCount. self {
316
+ guard newValue != state. totalFileCount else {
317
+ return
318
+ }
319
+
320
+ state. totalFileCount = newValue
321
+
322
+ totalFileCountDirty = true
323
+ } else if P . self == ProgressManager . Properties. CompletedFileCount. self {
324
+ guard newValue != state. completedFileCount else {
325
+ return
326
+ }
327
+
328
+ state. completedFileCount = newValue
329
+
330
+ completedFileCountDirty = true
331
+ } else {
332
+ guard newValue != state. propertiesInt [ MetatypeWrapper ( P . self) ] else {
333
+ return
334
+ }
335
+
336
+ state. propertiesInt [ MetatypeWrapper ( P . self) ] = newValue
424
337
425
- dirtyPropertiesInt. append ( MetatypeWrapper ( P . self) )
338
+ dirtyPropertiesInt. append ( MetatypeWrapper ( P . self) )
339
+ }
340
+
426
341
}
427
342
}
428
343
@@ -435,17 +350,42 @@ extension ProgressManager {
435
350
/// - Parameter key: A key path to the custom integer property type.
436
351
public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> UInt64 where P. Value == UInt64 , P. Summary == UInt64 {
437
352
get {
438
- return state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] ?? P . defaultValue
353
+ if P . self == ProgressManager . Properties. TotalByteCount. self {
354
+ return state. totalByteCount
355
+ } else if P . self == ProgressManager . Properties. CompletedByteCount. self {
356
+ return state. completedByteCount
357
+ } else {
358
+ return state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] ?? P . defaultValue
359
+ }
439
360
}
440
361
441
362
set {
442
- guard newValue != state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] else {
443
- return
444
- }
445
-
446
- state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] = newValue
363
+ if P . self == ProgressManager . Properties. TotalByteCount. self {
364
+ guard newValue != state. totalByteCount else {
365
+ return
366
+ }
367
+
368
+ state. totalByteCount = newValue
369
+
370
+ totalByteCountDirty = true
371
+ } else if P . self == ProgressManager . Properties. CompletedByteCount. self {
372
+ guard newValue != state. completedByteCount else {
373
+ return
374
+ }
375
+
376
+ state. completedByteCount = newValue
447
377
448
- dirtyPropertiesUInt64. append ( MetatypeWrapper ( P . self) )
378
+ completedByteCountDirty = true
379
+ } else {
380
+ guard newValue != state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] else {
381
+ return
382
+ }
383
+
384
+ state. propertiesUInt64 [ MetatypeWrapper ( P . self) ] = newValue
385
+
386
+ dirtyPropertiesUInt64. append ( MetatypeWrapper ( P . self) )
387
+
388
+ }
449
389
}
450
390
}
451
391
@@ -525,19 +465,33 @@ extension ProgressManager {
525
465
/// the getter returns the property's default value.
526
466
///
527
467
/// - Parameter key: A key path to the custom UInt64 property type.
528
- public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> UInt64 ? where P. Value == UInt64 , P. Summary == [ UInt64 ] {
468
+ public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> UInt64 where P. Value == UInt64 , P. Summary == [ UInt64 ] {
529
469
get {
530
- return state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] ?? P . self. defaultValue
470
+ if P . self == ProgressManager . Properties. Throughput. self {
471
+ return state. throughput
472
+ } else {
473
+ return state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] ?? P . self. defaultValue
474
+ }
531
475
}
532
476
533
477
set {
534
- guard newValue != state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] else {
535
- return
536
- }
478
+ if P . self == ProgressManager . Properties. Throughput. self {
479
+ guard newValue != state. throughput else {
480
+ return
481
+ }
482
+
483
+ state. throughput = newValue
484
+
485
+ throughputDirty = true
486
+ } else {
487
+ guard newValue != state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] else {
488
+ return
489
+ }
537
490
538
- state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] = newValue
491
+ state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] = newValue
539
492
540
- dirtyPropertiesUInt64Array. append ( MetatypeWrapper ( P . self) )
493
+ dirtyPropertiesUInt64Array. append ( MetatypeWrapper ( P . self) )
494
+ }
541
495
}
542
496
}
543
497
@@ -550,17 +504,31 @@ extension ProgressManager {
550
504
/// - Parameter key: A key path to the custom Duration property type.
551
505
public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> Duration where P. Value == Duration , P. Summary == Duration {
552
506
get {
553
- return state. propertiesDuration [ MetatypeWrapper ( P . self) ] ?? P . self. defaultValue
507
+ if P . self == ProgressManager . Properties. EstimatedTimeRemaining. self {
508
+ return state. estimatedTimeRemaining
509
+ } else {
510
+ return state. propertiesDuration [ MetatypeWrapper ( P . self) ] ?? P . self. defaultValue
511
+ }
554
512
}
555
513
556
514
set {
557
- guard newValue != state. propertiesDuration [ MetatypeWrapper ( P . self) ] else {
558
- return
559
- }
515
+ if P . self == ProgressManager . Properties. EstimatedTimeRemaining. self {
516
+ guard newValue != state. estimatedTimeRemaining else {
517
+ return
518
+ }
519
+
520
+ state. estimatedTimeRemaining = newValue
560
521
561
- state. propertiesDuration [ MetatypeWrapper ( P . self) ] = newValue
522
+ estimatedTimeRemainingDirty = true
523
+ } else {
524
+ guard newValue != state. propertiesDuration [ MetatypeWrapper ( P . self) ] else {
525
+ return
526
+ }
527
+
528
+ state. propertiesDuration [ MetatypeWrapper ( P . self) ] = newValue
562
529
563
- dirtyPropertiesDuration. append ( MetatypeWrapper ( P . self) )
530
+ dirtyPropertiesDuration. append ( MetatypeWrapper ( P . self) )
531
+ }
564
532
}
565
533
}
566
534
0 commit comments