예제 #1
0
파일: Utils.cs 프로젝트: rsumner31/corefx2
        public static void InsertItems <TKey, TValue>(
            this KeyedCollection <TKey, TValue> collection,
            Func <TValue> generateItem,
            Func <TValue, TKey> getKey,
            int numItems,
            out TKey[] keys,
            out TValue[] items,
            out TValue[] itemsWithKeys)
        {
            items         = new TValue[numItems];
            keys          = new TKey[numItems];
            itemsWithKeys = new TValue[numItems];
            var keyIndex = 0;

            for (var i = 0; i < numItems; ++i)
            {
                TValue item = generateItem();
                TKey   key  = getKey(item);

                collection.Insert(collection.Count, item);
                items[i] = item;

                if (null != key)
                {
                    keys[keyIndex]          = key;
                    itemsWithKeys[keyIndex] = item;
                    ++keyIndex;
                }
            }

            keys          = keys.Slice(0, keyIndex);
            itemsWithKeys = itemsWithKeys.Slice(0, keyIndex);
        }
예제 #2
0
 public void Insert(int index, string key, WizardPanel item)
 {
     m_Panels.Insert(index, key, item);
     if (InsertPanel != null)
     {
         InsertPanel(item, index);
     }
 }