Exemple #1
0
bool Control::WriteAll(const std::vector< tstring >& strs, bool preview)
{
  StringData* data = CastData<StringData, DataTypes::String>( m_BoundData );
  if (data)
  {
    std::vector< tstring > currentValues;
    data->GetAll( currentValues );

    if ( strs == currentValues )
    {
      return true;
    }

    Reflect::SerializerPtr serializer = Reflect::AssertCast< Reflect::Serializer >( Reflect::Serializer::Create< std::vector< tstring > >() );
    serializer->ConnectData( const_cast< std::vector< tstring >* >( &strs ) );
    if ( !PreWrite( serializer, preview ) )
    {
      Read();
      return false;
    }

    m_Writing = true;

    bool result = data->SetAll( strs );
    m_Writing = false;

    if (result)
    {
      PostWrite();
      return true;
    }
  }

  HELIUM_BREAK(); // you should not call this, your control is using custom data
  return false;
}