Exemplo n.º 1
0
        /// <summary>
        /// Store a given value if the given key isn't already used
        /// for a value of that type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        public static void AddItem <T>(RescItem <T> item)
        {
            RescItemKey rescItemKey = new RescItemKey(item.Name.NormaliseString(), typeof(T));

            if (!items.ContainsKey(rescItemKey))
            {
                items.Add(rescItemKey, item.Item);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// A method which returns true if a resource of the
        /// given type and name is stored and outputs said
        /// resource.
        /// </summary>
        /// <typeparam name="T">The type of the requested resource.</typeparam>
        /// <param name="key">The name of the requested resource.</param>
        /// <param name="item">The outputted resource (if it is found).</param>
        /// <returns></returns>
        public static bool GetItem <T>(string key, out T item)
        {
            Type        type        = typeof(T);
            RescItemKey rescItemKey = new RescItemKey(key.NormaliseString(), type);

            if (items.ContainsKey(rescItemKey))
            {
                item = (T)(items[rescItemKey]);
                return(true);
            }
            item = default(T);
            return(false);
        }