コード例 #1
0
        /// <summary>
        /// Get the value of a variable defined at a certain scope by name
        /// </summary>
        /// <param name="name">name of the variable</param>
        /// <param name="scope">scope at which the variable is defined</param>
        /// <returns>returns the value of the variable (or null if not existent or exception if you really want to mess things up, dude!)</returns>
        public T GetVariable <T>(string name, EVariableScope scope)
        {
            object o = GetVariable(name, scope);

            if (o == null)
            {
                return(default(T));
            }

            return((T)o);
        }
コード例 #2
0
        // ===============================================================================================================================================
        // ===============================================================================================================================================

        /// <summary>
        /// Get the value of a variable defined at a certain scope by name
        /// </summary>
        /// <param name="name">name of the variable</param>
        /// <param name="scope">scope at which the variable is defined</param>
        /// <returns>returns the value of the variable (or null if not existent or exception if you really want to mess things up, dude!)</returns>
        public object GetVariable(string name, EVariableScope scope)
        {
            switch (scope)
            {
            case EVariableScope.File:
                return(GetFileVariable(name));

            case EVariableScope.User:
                return(GetUserVariable(name));

            case EVariableScope.FileAndUser:
                return(GetUserFileVariable(name));

            case EVariableScope.Global:
                return(GetGlobalVariable(name));

            default:
                throw new Exception("Error: The scope has to be set to one of the predefined states!");
            }
        }
コード例 #3
0
        // ===============================================================================================================================================
        // ===============================================================================================================================================

        /// <summary>
        /// Set the value of a variable defined at a certain scope by name
        /// </summary>
        /// <typeparam name="T">The type of the value</typeparam>
        /// <param name="name">name of the variable</param>
        /// <param name="value">the value to set to the variable</param>
        /// <param name="scope">scope at which the variable is/will be defined</param>
        public void SetVariable <T>(string name, T value, EVariableScope scope)
        {
            switch (scope)
            {
            case EVariableScope.File:
                SetFileVariable(name, value);
                break;

            case EVariableScope.User:
                SetUserVariable(name, value);
                break;

            case EVariableScope.FileAndUser:
                SetUserFileVariable(name, value);
                break;

            case EVariableScope.Global:
                SetGlobalVariable(name, value);
                break;

            default:
                throw new Exception("Error: The scope has to be set to one of the predefined states!");
            }
        }