Exemplo n.º 1
0
        /// <summary>
        /// Sets the supplied configuration value.
        /// </summary>
        /// <typeparam name="TConfig">Type of the configuration value.</typeparam>
        /// <param name="Scope">Configuration scope.</param>
        /// <param name="Code">Key code that identificates the value.</param>
        /// <param name="Value">Configuration value to store.</param>
        /// <param name="SaveNow">Optionally, makes persistent (All) the configuration information.</param>
        public static void SetConfiguration <TConfig>(string Scope, string Code, TConfig Value, bool SaveNow = false)
        {
            General.ContractRequiresNotAbsent(Scope, Code);
            General.ContractRequires(Scope.IsValidIdentifier(), Code.IsValidIdentifier());
            var ConfigKey = Scope + CONFIG_SCOPESEPARATOR + Code;

            try
            {
                var StringValue = (string)Convert.ChangeType(Value, typeof(string));
                CurrentConfiguration[ConfigKey] = StringValue;
            }
            catch (Exception Problem)
            {
                throw new UsageAnomaly("Cannot set configuration value for key [" + ConfigKey + "].", Problem);
            }

            if (SaveNow)
            {
                AppExec.StoreConfigurationTo();
            }
        }
Exemplo n.º 2
0
        // -------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the application's temporary folder.
        /// </summary>
        // IMPORTANT:
        // Changes in Configuration may be used only until next application execution (see DetailAttachmentEditor).
        public static string GetTempFolder()
        {
            var Result = AppExec.GetConfiguration <string>("Application", "TempFolder", Path.GetTempPath());

            return(Result);
        }