Exemplo n.º 1
0
        /// <summary>
        /// Returns storage content.
        /// </summary>
        /// <param name="type">The type of the storage content.</param>
        /// <param name="name">The name of the storage content.</param>
        public static object GetObject(string type, string name)
        {
            switch (type.ToLower())
            {
            case "pokemon":
                if (Pokemons.ContainsKey(name))
                {
                    return(Pokemons[name]);
                }
                break;

            case "string":
            case "str":
                if (Strings.ContainsKey(name))
                {
                    return(Strings[name]);
                }
                break;

            case "integer":
            case "int":
                if (Integers.ContainsKey(name))
                {
                    return(Integers[name]);
                }
                break;

            case "boolean":
            case "bool":
                if (Booleans.ContainsKey(name))
                {
                    return(Booleans[name]);
                }
                break;

            case "item":
                if (Items.ContainsKey(name))
                {
                    return(Items[name]);
                }
                break;

            case "single":
            case "sng":
                if (Singles.ContainsKey(name))
                {
                    return(Singles[name]);
                }
                break;

            case "double":
            case "dbl":
                if (Doubles.ContainsKey(name))
                {
                    return(Doubles[name]);
                }
                break;
            }

            return(ScriptVersion2.ScriptComparer.DefaultNull);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds or updates storage content.
        /// </summary>
        /// <param name="type">The type of the storage content.</param>
        /// <param name="name">The name of the storage content.</param>
        /// <param name="newContent">The new storage content.</param>
        public static void SetObject(string type, string name, object newContent)
        {
            switch (type.ToLower())
            {
            case "pokemon":
                if (Pokemons.ContainsKey(name))
                {
                    Pokemons[name] = (BasePokemon)newContent;
                }
                else
                {
                    Pokemons.Add(name, (BasePokemon)newContent);
                }
                break;

            case "string":
            case "str":
                if (Strings.ContainsKey(name))
                {
                    Strings[name] = Convert.ToString(newContent);
                }
                else
                {
                    Strings.Add(name, Convert.ToString(newContent));
                }
                break;

            case "integer":
            case "int":
                if (Integers.ContainsKey(name))
                {
                    Integers[name] = @int(newContent);
                }
                else
                {
                    Integers.Add(name, @int(newContent));
                }
                break;

            case "boolean":
            case "bool":
                if (Booleans.ContainsKey(name))
                {
                    Booleans[name] = Convert.ToBoolean(newContent);
                }
                else
                {
                    Booleans.Add(name, Convert.ToBoolean(newContent));
                }
                break;

            case "item":
                if (Items.ContainsKey(name))
                {
                    Items[name] = (BaseItem)newContent;
                }
                else
                {
                    Items.Add(name, (BaseItem)newContent);
                }
                break;

            case "single":
            case "sng":
                if (Singles.ContainsKey(name))
                {
                    Singles[name] = sng(newContent);
                }
                else
                {
                    Singles.Add(name, sng(newContent));
                }
                break;

            case "double":
            case "dbl":
                if (Doubles.ContainsKey(name))
                {
                    Doubles[name] = dbl(newContent);
                }
                else
                {
                    Doubles.Add(name, dbl(newContent));
                }
                break;
            }
        }