Beispiel #1
0
        /// <summary>
        /// Deserializes stored data
        /// </summary>
        /// <param name="doInParaller">if set to <c>true</c> [do in paraller].</param>
        /// <returns></returns>
        protected Dictionary <String, T> GetDataItems(Boolean doInParaller = true)
        {
            aceConcurrentBag <instanceItemContainer <T> > bag = new aceConcurrentBag <instanceItemContainer <T> >();
            Dictionary <String, T> output = new Dictionary <String, T>();

            if (doInParaller)
            {
                Parallel.ForEach(bagContent, (i) =>
                {
                    bag.Add(GetItem(i));
                });
            }
            else
            {
                foreach (var i in bagContent)
                {
                    bag.Add(GetItem(i));
                }
            }

            foreach (var i in bag)
            {
                output.Add(i.id, i.instance);
                if (i.instance is IDataPackageItem)
                {
                    IDataPackageItem item_IDataPackageItem = (IDataPackageItem)i.instance;
                    item_IDataPackageItem.OnLoaded();
                }
            }

            return(output);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the data items.
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="doInParaller">if set to <c>true</c> [do in paraller].</param>
        /// <returns></returns>
        protected aceConcurrentBag <dataItemContainer> AddDataItems(IEnumerable <TWrapper> items, Boolean doInParaller = true)
        {
            aceConcurrentBag <dataItemContainer> bag = new aceConcurrentBag <dataItemContainer>();

            if (doInParaller)
            {
                Parallel.ForEach(items, (i) =>
                {
                    bag.Add(AddDataItem(i));
                });
            }
            else
            {
                foreach (var i in items)
                {
                    bag.Add(AddDataItem(i));
                }
            }
            return(bag);
        }