{
    // Get the adapter from the factory.
    //
    ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProvider.class);

    // No color is a good default.
    //
    Object result = null;

    // Now we could check that the adapter implements interface ITableItemColorProvider.
    //
    if (tableItemColorProvider  != null)
    {
      // And delegate the call.
      //
      result = tableItemColorProvider.getForeground(object, columnIndex);
    }
    // Otherwise, we could check that the adapter implements interface IItemColorProvider.
    //
    else
    {
      IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProvider.class);
      if (itemColorProvider != null)
      {
        // And delegate the call.
        //
        result = itemColorProvider.getForeground(object);
      }
    }

    return result;
  }