Beispiel #1
0
        /// <summary>
        /// Return a content item if it is already loaded, otherwise load the content item syncronously.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="uri"></param>
        /// <param name="enque"></param>
        /// <returns></returns>
        public ContentItem Get <T>(string uri, bool enque = false)
        {
            ContentItem item;

            lock (_contentItems)
            {
                if (_contentItems.Contains(uri))
                {
                    return(_contentItems[uri]);
                }
                else
                {
                    item = new ContentItem(uri, null);
                    _contentItems.Add(item);
                }
            }
            item.loader = Loader <T>;
            if (enque)
            {
                _loadQueue.Enqueue(item);
            }
            else
            {
                item.LoadingStatus = LoadingStatus.Loading;
                item.loader(item);
                item.LoadingStatus = LoadingStatus.Loaded;
            }
            return(item);
        }