Exemplo n.º 1
0
        /// <summary>
        /// Replaces an entry with a new one
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="NewEntry"></param>
        /// <returns></returns>
        public ResourceEntry <T> ReplaceEntry(string Key, ResourceEntry <T> NewEntry)
        {
            //If registry does not contain the key, simply register it and return null
            if (!Registry.ContainsKey(Key))
            {
                RegisterEntry(Key, NewEntry);
                return(null);
            }

            //else retrieve the previous entry, remove it and register the new one. Finally return the previous one
            ResourceEntry <T> temp = Registry[Key];

            Registry.Remove(Key);
            RegisterEntry(Key, NewEntry);
            return(temp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Register a new entry.
        /// </summary>
        /// <param name="Key">Key to register (I.E.: unlocalized entry)</param>
        /// <param name="Entry"></param>
        /// <returns></returns>
        public bool RegisterEntry(string Key, ResourceEntry <T> Entry)
        {
            //Cannot add a value in a null key
            if (Key == null)
            {
                return(false);
            }

            //Cannot add a null value
            if (Entry == null)
            {
                return(false);
            }

            //Value already contained
            if (Registry.ContainsKey(Key))
            {
                return(false);
            }

            //Successfully add the key
            Registry.Add(Key, Entry);
            return(true);
        }