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 copyTierProg(QbItemStruct prog, int toTierNo, params string[] qbKeyMask)
        {
            QbItemStruct copy = (QbItemStruct)prog.Clone();

            //replace all 1s for our new number
            copy.FindItem(true, delegate(QbItemBase qib)
                {
                    if (qib.ItemQbKey != null)
                    {
                        if (qib is QbItemInteger && qib.ItemQbKey.Crc == QbKey.Create("tier").Crc)
                            ((QbItemInteger)qib).Values[0] = (uint)toTierNo;
                        else if (qib is QbItemQbKey)
                        {
                            foreach (string s in qbKeyMask)
                            {
                                QbKey k = QbKey.Create(string.Format(s, "1"));
                                QbKey k2 = QbKey.Create(string.Format(s, "0"));

                                if (((QbItemQbKey)qib).Values[0].Crc == k.Crc)
                                    ((QbItemQbKey)qib).Values[0] = QbKey.Create(string.Format(s, toTierNo.ToString()));
                                else if (((QbItemQbKey)qib).Values[0].Crc == k2.Crc)
                                    ((QbItemQbKey)qib).Values[0] = QbKey.Create(string.Format(s, (toTierNo - 1).ToString()));
                            }
                        }
                    }
                    return false; //return false to continue search
                });
            return copy;
        }
Beispiel #2
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;
        }