@@ -293,116 +293,6 @@ extension ProgressManager {
293293 }
294294 }
295295
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-
406296 /// Gets or sets custom integer properties.
407297 ///
408298 /// This subscript provides read-write access to custom progress properties where both the value
@@ -412,17 +302,42 @@ extension ProgressManager {
412302 /// - Parameter key: A key path to the custom integer property type.
413303 public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> Int where P. Value == Int , P. Summary == Int {
414304 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+ }
416312 }
417313
418314 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
424337
425- dirtyPropertiesInt. append ( MetatypeWrapper ( P . self) )
338+ dirtyPropertiesInt. append ( MetatypeWrapper ( P . self) )
339+ }
340+
426341 }
427342 }
428343
@@ -435,17 +350,42 @@ extension ProgressManager {
435350 /// - Parameter key: A key path to the custom integer property type.
436351 public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> UInt64 where P. Value == UInt64 , P. Summary == UInt64 {
437352 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+ }
439360 }
440361
441362 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
447377
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+ }
449389 }
450390 }
451391
@@ -525,19 +465,33 @@ extension ProgressManager {
525465 /// the getter returns the property's default value.
526466 ///
527467 /// - 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 ] {
529469 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+ }
531475 }
532476
533477 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+ }
537490
538- state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] = newValue
491+ state. propertiesUInt64Array [ MetatypeWrapper ( P . self) ] = newValue
539492
540- dirtyPropertiesUInt64Array. append ( MetatypeWrapper ( P . self) )
493+ dirtyPropertiesUInt64Array. append ( MetatypeWrapper ( P . self) )
494+ }
541495 }
542496 }
543497
@@ -550,17 +504,31 @@ extension ProgressManager {
550504 /// - Parameter key: A key path to the custom Duration property type.
551505 public subscript< P: Property > ( dynamicMember key: KeyPath < ProgressManager . Properties , P . Type > ) -> Duration where P. Value == Duration , P. Summary == Duration {
552506 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+ }
554512 }
555513
556514 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
560521
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
562529
563- dirtyPropertiesDuration. append ( MetatypeWrapper ( P . self) )
530+ dirtyPropertiesDuration. append ( MetatypeWrapper ( P . self) )
531+ }
564532 }
565533 }
566534
0 commit comments