bool ComponentCollection::CopyComponentTo( ComponentCollection& destCollection, const ComponentPtr& destAttrib, const ComponentPtr& srcAttrib )
{
    bool inserted = false;
    Reflect::Registry* registry = Reflect::Registry::GetInstance();

    tstring unused;
    // If there is already an component in the destination slot, or the
    // component is not in the destination, but is allowed to be...
    if ( destCollection.ValidateComponent( destAttrib, unused ) )
    {
        // Component can be added to the destination collection, so do it!
        srcAttrib->CopyTo( destAttrib );
        destCollection.SetComponent( destAttrib, false );
        inserted = true;
    }
    else
    {
        ComponentPtr existing = destCollection.GetComponent( destAttrib->GetSlot() );
        if ( existing.ReferencesObject() )
        {
            destCollection.RemoveComponent( existing->GetSlot() );
            if ( destCollection.ValidateComponent( destAttrib, unused ) )
            {
                srcAttrib->CopyTo( destAttrib );
                destCollection.SetComponent( destAttrib, false );
                inserted = true;
            }
            else
            {
                destCollection.SetComponent( existing, false );
            }
        }
    }

    return inserted;
}