Clone() public method

Deep clones this item and all children. Positions and lengths are not cloned. When inserted in to another item they should be calculated.
public Clone ( ) : QbItemBase
return QbItemBase
Beispiel #1
0
        private QbItemStruct copyCareerTiers(QbItemStruct careerSongsSec, QbItemStruct toTier)
        {
            //all other tier structs have encore2 in them so add it. and no completion movie item
            QbItemBase tmp;

            QbKey qkInitialMovie = QbKey.Create("initial_movie");
            QbKey qkCompletionMovie = QbKey.Create("completion_movie");
            QbKey qkEncoreP1 = QbKey.Create("encorep1");

            QbKey qkPrefix = QbKey.Create("prefix");
            string prefix = ((QbItemString)toTier.FindItem(qkPrefix, false)).Strings[0];

            QbItemStruct to = (QbItemStruct)careerSongsSec.Clone();

            if ((tmp = to.FindItem(qkInitialMovie, false)) != null)
                to.RemoveItem(tmp); //remove initial move if found

            to.ItemQbKey = toTier.ItemQbKey.Clone();
            ((QbItemString)to.FindItem(qkPrefix, false)).Strings[0] = prefix;

            QbItemQbKey encorep2 = new QbItemQbKey(to.Root);
            encorep2.Create(QbItemType.StructItemQbKey);
            encorep2.Values = new QbKey[] { QbKey.Create("encorep2") };

            foreach (QbItemBase qb in to.Items)
            {
                if (qb.QbItemType == QbItemType.StructItemStruct)
                {
                    if ((tmp = qb.FindItem(qkCompletionMovie, false)) != null)
                        qb.RemoveItem(tmp); //remove initial move if found

                    if ((tmp = qb.FindItem(false, delegate (QbItemBase q)
                        {
                            return (qb.QbItemType == QbItemType.StructItemQbKey && qb.ItemQbKey != null && qb.ItemQbKey.Crc == 0 && ((QbItemQbKey)qb).Values[0].Crc == qkEncoreP1.Crc);
                        })) != null)
                    {
                        qb.InsertItem(encorep2.Clone(), tmp, false);
                    }
                }
            }

            return to;
        }