Quintiq file version 2.0
#parent: #root
Method ReadValue (NamedValueTree nvt, NamedValue nv) as shadow[LibSE_Setting] id:Method_DialogSettingsEngine_ReadValue
{
  #keys: '[139164.3.1812419430]'
  Body:
  [*
    value := nv.GetValue();
    
    handle_metadata := nvt.GetHandle( LibSE_SettingsContainer::Handle_Metadata() );
    handle_default_value := nvt.GetHandle( LibSE_SettingsContainer::Handle_DefaultValue() );
    default_value := guard( nv.Child( handle_metadata ).Child( handle_default_value ), null( NamedValue ) );
    
    new := null( shadow[LibSE_Setting] );
    if( value.istype( BinaryValue ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingBinaryValue,
                                      Type := "BinaryValue",
                                      Value := nv.GetValueAsBinaryValue() );
      new := setting;
    }
    else if( value.istype( Boolean ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingBoolean,
                                      Type := "Boolean",
                                      Value := nv.GetValueAsBoolean() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsBoolean() );
      }
      new := setting;
    }
    else if( value.istype( Char ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingChar,
                                      Type := "Char",
                                      Value := nv.GetValueAsChar() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsChar() );
      }
      new := setting;
    }
    else if( value.istype( Date ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingDate,
                                      Type := "Date",
                                      Value := nv.GetValueAsDate() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsDate() );
      }
      new := setting;
    }
    else if( value.istype( DateTime ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingDateTime,
                                      Type := "DateTime",
                                      Value := nv.GetValueAsDateTime() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsDateTime() );
      }
      new := setting;
    }
    else if( value.istype( Duration ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingDuration,
                                      Type := "Duration",
                                      Value := nv.GetValueAsDuration() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsDuration() );
      }
      new := setting;
    }
    else if( value.istype( Key ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingKey,
                                      Type := "Key",
                                      Value := nv.GetValueAsKey() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsKey() );
      }
      new := setting;
    }
    else if( value.istype( Number ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingNumber,
                                      Type := "Number",
                                      Value := nv.GetValueAsNumber() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsNumber() );
      }
      new := setting;
    }
    else if( value.istype( Real ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingReal,
                                      Type := "Real",
                                      Value := nv.GetValueAsReal() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsReal() );
      }
      new := setting;
    }
    else if( value.istype( String ) )
    {
      setting := this.Data().Setting( relnew,
                                      LibSE_SettingString,
                                      Type := "String",
                                      Value := nv.GetValueAsString() );
      if( not isnull( default_value ) )
      {
        setting.Default( default_value.GetValueAsString() );
      }
      new := setting;
    }
    
    return new;
  *]
}
