@@ -123,6 +123,21 @@ public AttributeValuesDouble(double? initialValue = null,
123123 }
124124 }
125125
126+ internal class AttributeValuesDateTime : AttributeValueContainer
127+ {
128+ public AttributeValuesDateTime ( DateTime ? initialValue = null ,
129+ AttributeVersion initialVersion = AttributeVersion . Original ,
130+ bool isMarkedForDeletion = false )
131+ {
132+ _myValueType = typeof ( DateTime ) ;
133+ _valueDict = new Dictionary < AttributeVersion , Tuple < DateTime , bool > > ( ) ;
134+ if ( initialValue != null )
135+ {
136+ _valueDict [ key : initialVersion ] = new Tuple < DateTime , bool > ( item1 : ( DateTime ) initialValue , item2 : isMarkedForDeletion ) ;
137+ }
138+ }
139+ }
140+
126141 #endregion
127142
128143 #region Private variables
@@ -293,6 +308,14 @@ public bool IsMarkedForDeletion(ElementAttribute attribute,
293308 . Item2 ;
294309 }
295310
311+ if ( attributeType == typeof ( DateTime ) )
312+ {
313+ IDictionary < AttributeVersion , Tuple < DateTime , bool > > DateTimeDict = ( IDictionary < AttributeVersion , Tuple < DateTime , bool > > ) avc . ValueDict ;
314+ Tuple < DateTime , bool > doubleValue = DateTimeDict [ key : version ] ;
315+ return DateTimeDict [ key : version ]
316+ . Item2 ;
317+ }
318+
296319 // else
297320 // Should not get to here
298321 throw new ArgumentException ( message : $ "Failed to retrieve attribute '{ GetAttributeName ( attribute : attribute ) } " +
@@ -373,6 +396,19 @@ public string GetAttributeValueString(ElementAttribute attribute,
373396 return doubleValue . Item1 . ToString ( provider : CultureInfo . InvariantCulture ) ;
374397 }
375398
399+ if ( attributeType == typeof ( DateTime ) )
400+ {
401+ IDictionary < AttributeVersion , Tuple < DateTime , bool > > dateTimeDict = ( IDictionary < AttributeVersion , Tuple < DateTime , bool > > ) avc . ValueDict ;
402+ Tuple < DateTime , bool > dateTimeValue = dateTimeDict [ key : versionToReturn ] ;
403+ if ( dateTimeDict [ key : versionToReturn ]
404+ . Item2 )
405+ {
406+ return FrmMainApp . NullStringEquivalentGeneric ;
407+ }
408+
409+ return dateTimeValue . Item1 . ToString ( provider : CultureInfo . CurrentUICulture ) ;
410+ }
411+
376412 // else
377413 // Should not get to here
378414 throw new ArgumentException ( message : $ "Failed to retrieve attribute '{ GetAttributeName ( attribute : attribute ) } " +
@@ -446,8 +482,17 @@ public string GetAttributeValueString(ElementAttribute attribute,
446482 return ( T ) Convert . ChangeType ( value : doubleValue , conversionType : typeof ( T ) ) ;
447483 }
448484 }
485+ else if ( attributeType == typeof ( DateTime ) )
486+ {
487+ IDictionary < AttributeVersion , Tuple < DateTime , bool > > DateTimeDict = ( IDictionary < AttributeVersion , Tuple < DateTime , bool > > ) avc . ValueDict ;
488+ DateTime DateTimeValue = DateTimeDict [ key : versionToReturn ]
489+ . Item1 ;
490+ if ( requestType == typeof ( DateTime ) )
491+ {
492+ return ( T ) Convert . ChangeType ( value : DateTimeValue , conversionType : typeof ( T ) ) ;
493+ }
494+ }
449495
450- // else
451496 // Should not get to here
452497 throw new ArgumentException ( message : $ "Failed to retrieve attribute '{ GetAttributeName ( attribute : attribute ) } " +
453498 $ "' of type '{ attributeType . Name } " +
@@ -467,6 +512,7 @@ public void SetAttributeValueAnyType(ElementAttribute attribute,
467512 bool isMarkedForDeletion )
468513 {
469514 Type typeOfAttribute = GetAttributeType ( attribute : attribute ) ;
515+ IConvertible writeValueConvertible = null ;
470516
471517 if ( typeOfAttribute == typeof ( string ) )
472518 {
@@ -477,17 +523,25 @@ public void SetAttributeValueAnyType(ElementAttribute attribute,
477523 }
478524 else if ( typeOfAttribute == typeof ( double ) )
479525 {
480- double ? writeValueDbl = HelperGenericTypeOperations . TryParseNullableDouble ( val : value ) ;
526+ writeValueConvertible = HelperGenericTypeOperations . TryParseNullableDouble ( val : value ) ?? FrmMainApp . NullDoubleEquivalent ;
481527 SetAttributeValue ( attribute : attribute ,
482- value : writeValueDbl ,
528+ value : writeValueConvertible ,
483529 version : version ,
484530 isMarkedForDeletion : isMarkedForDeletion ) ;
485531 }
486532 else if ( typeOfAttribute == typeof ( int ) )
487533 {
488- int ? writeValueInt = HelperGenericTypeOperations . TryParseNullableInt ( val : value ) ;
534+ writeValueConvertible = HelperGenericTypeOperations . TryParseNullableInt ( val : value ) ?? FrmMainApp . NullIntEquivalent ;
489535 SetAttributeValue ( attribute : attribute ,
490- value : writeValueInt ,
536+ value : writeValueConvertible ,
537+ version : version ,
538+ isMarkedForDeletion : isMarkedForDeletion ) ;
539+ }
540+ else if ( typeOfAttribute == typeof ( DateTime ) )
541+ {
542+ writeValueConvertible = HelperGenericTypeOperations . TryParseNullableDateTime ( val : value ) ?? FrmMainApp . NullDateTimeEquivalent ;
543+ SetAttributeValue ( attribute : attribute ,
544+ value : writeValueConvertible ,
491545 version : version ,
492546 isMarkedForDeletion : isMarkedForDeletion ) ;
493547 }
@@ -551,6 +605,19 @@ public void SetAttributeValue(ElementAttribute attribute,
551605 . ValueDict [ key : version ] = new Tuple < int , bool > ( item1 : ( int ) value , item2 : isMarkedForDeletion ) ;
552606 }
553607 }
608+ else if ( attributeType == typeof ( DateTime ) )
609+ {
610+ if ( setMarkedForDeletion )
611+ {
612+ _Attributes [ key : attribute ]
613+ . ValueDict [ key : version ] = new Tuple < DateTime , bool > ( item1 : FrmMainApp . NullDateTimeEquivalent , item2 : isMarkedForDeletion ) ;
614+ }
615+ else
616+ {
617+ _Attributes [ key : attribute ]
618+ . ValueDict [ key : version ] = new Tuple < DateTime , bool > ( item1 : ( DateTime ) value , item2 : isMarkedForDeletion ) ;
619+ }
620+ }
554621 else if ( attributeType == typeof ( string ) )
555622 {
556623 if ( setMarkedForDeletion )
@@ -588,6 +655,11 @@ public void SetAttributeValue(ElementAttribute attribute,
588655 value ??= FrmMainApp . NullIntEquivalent ;
589656 avc = new AttributeValuesInt ( initialValue : ( int ) value , initialVersion : version , isMarkedForDeletion : isMarkedForDeletion ) ;
590657 }
658+ else if ( attributeType == typeof ( DateTime ) )
659+ {
660+ value ??= FrmMainApp . NullDateTimeEquivalent ;
661+ avc = new AttributeValuesDateTime ( initialValue : ( DateTime ) value , initialVersion : version , isMarkedForDeletion : isMarkedForDeletion ) ;
662+ }
591663 else
592664 {
593665 value ??= FrmMainApp . NullStringEquivalentGeneric ;
@@ -780,8 +852,11 @@ private bool ParseAttribute(ElementAttribute attribute,
780852 case ElementAttribute . Fnumber :
781853 case ElementAttribute . FocalLength :
782854 case ElementAttribute . FocalLengthIn35mmFormat :
855+ resTyped = TagsToModelValueTransformations . T2M_F_FocalLength ( attribute : attribute , parseResult : parseResult ) ;
856+ break ;
857+
783858 case ElementAttribute . ISO :
784- resTyped = TagsToModelValueTransformations . T2M_F_FocalLength_ISO ( attribute : attribute , parseResult : parseResult ) ;
859+ resTyped = TagsToModelValueTransformations . T2M_F_ISO ( attribute : attribute , parseResult : parseResult ) ;
785860 break ;
786861
787862 case ElementAttribute . TakenDate :
0 commit comments