예제 #1
0
        /// <summary>
        /// Returns a deep-copy list of filtered kaomojis from a single category.
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public static List <Kaomoji> GetKaomojis(RegistryFilter filter, KaomojiFlags.Category flag)
        {
            //Load data if not already loaded.
            if (!KaomojiDataHandler.IsLoaded)
            {
                KaomojiDataHandler.Load();
            }

            List <Kaomoji> filterCopy = new List <Kaomoji>();

            foreach (Kaomoji kaomoji in Registry)
            {
                if (filter == RegistryFilter.AllowOnly)
                {
                    if (!kaomoji.Flags.ContainsFlag(flag))
                    {
                        continue;
                    }
                }
                //if(filter == RegistryFilter.Exclude)
                //TODO change this if more filters are added!
                else
                {
                    if (kaomoji.Flags.ContainsFlag(flag))
                    {
                        continue;
                    }
                }
                filterCopy.Add((Kaomoji)kaomoji.Clone());
            }

            return(filterCopy);
        }
예제 #2
0
        /// <summary>
        /// Returns a deep-copy list of all kaomojis.
        /// </summary>
        public static List <Kaomoji> GetKaomojis()
        {
            //Load data if not already loaded.
            if (!KaomojiDataHandler.IsLoaded)
            {
                KaomojiDataHandler.Load();
            }

            List <Kaomoji> regCopy = new List <Kaomoji>(Registry.Count);

            Registry.ForEach((item) => {
                regCopy.Add((Kaomoji)item.Clone());
            });
            return(regCopy);
        }
예제 #3
0
        private static Kaomoji GetRandom(bool clone)
        {
            //Load data if not already loaded.
            if (!KaomojiDataHandler.IsLoaded)
            {
                KaomojiDataHandler.Load();
            }

            //Find a random value in the registry.
            Random  rnd = new Random();
            Kaomoji k   = Registry[rnd.Next(0, Registry.Count)];

            if (clone)
            {
                k = (Kaomoji)k.Clone();
            }

            return(k);
        }