Nanook.QueenBee.Parser.QbItemStruct.Clone C# (CSharp) Метод

Clone() публичный Метод

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
Результат QbItemBase
        public override QbItemBase Clone()
        {
            QbItemStruct s = new QbItemStruct(this.Root);
            s.Create(this.QbItemType);

            if (this.ItemQbKey != null)
                s.ItemQbKey = this.ItemQbKey.Clone();

            foreach (QbItemBase qib in this.Items)
                s.Items.Add(qib.Clone());

            s.ItemCount = this.ItemCount;

            return s;
        }

Usage Example

Пример #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;
        }
All Usage Examples Of Nanook.QueenBee.Parser.QbItemStruct::Clone