本文整理汇总了C#中System.Configuration.Configuration类的典型用法代码示例。如果您正苦于以下问题:C# Configuration类的具体用法?C# Configuration怎么用?C# Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于System.Configuration命名空间,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSectionGroup
public static SerializationSectionGroup GetSectionGroup (ConfigurationType config)
{
var ret = (SerializationSectionGroup) config.GetSectionGroup ("system.runtime.serialization");
if (ret == null)
throw new SystemException ("Internal configuration error: section 'system.runtime.serialization' was not found.");
return ret;
}
示例2: OptionsForm
private OptionsForm(bool local)
{
InitializeComponent();
// Copy the Bootstrap.exe file to New.exe,
// so that the configuration file will load properly
string currentDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string sandboxDir = Path.Combine(currentDir, "Sandbox");
if (!File.Exists(Path.Combine(sandboxDir, "New.exe")))
{
File.Copy(
Path.Combine(sandboxDir, "Bootstrap.exe"),
Path.Combine(sandboxDir, "New.exe")
);
}
string filename = local ? "New.exe" : "Bootstrap.exe";
string filepath = Path.Combine(sandboxDir, filename);
_Configuration = ConfigurationManager.OpenExeConfiguration(filepath);
// Get the DDay.Update configuration section
_Cfg = _Configuration.GetSection("DDay.Update") as DDayUpdateConfigurationSection;
// Set the default setting on which application folder to use.
cbAppFolder.SelectedIndex = 0;
SetValuesFromConfig();
if (!local)
_Configuration.SaveAs(Path.Combine(sandboxDir, "New.exe.config"));
}
示例3: AddModule
// https://msdn.microsoft.com/en-us/library/tkwek5a4%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
// Example Configuration Code for an HTTP Module:
public static void AddModule(Configuration config, string moduleName, string moduleClass)
{
HttpModulesSection section =
(HttpModulesSection)config.GetSection("system.web/httpModules");
// Create a new module action object.
HttpModuleAction moduleAction = new HttpModuleAction(
moduleName, moduleClass);
// "RequestTimeIntervalModule", "Samples.Aspnet.HttpModuleExamples.RequestTimeIntervalModule");
// Look for an existing configuration for this module.
int indexOfModule = section.Modules.IndexOf(moduleAction);
if (-1 != indexOfModule)
{
// Console.WriteLine("RequestTimeIntervalModule module is already configured at index {0}", indexOfModule);
}
else
{
section.Modules.Add(moduleAction);
if (!section.SectionInformation.IsLocked)
{
config.Save();
// Console.WriteLine("RequestTimeIntervalModule module configured.");
}
}
}
示例4: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
//操作appSettings
AppSettingsSection appseting = (AppSettingsSection)Configuration.GetSection("appSettings"); //修改设置
try
{
appseting.Settings["txtiosapplink"].Value = this.txtiosapplink.Text;
}
catch (Exception)
{
appseting.Settings.Add("txtiosapplink", this.txtiosapplink.Text);
}
try
{
appseting.Settings["txtapklink"].Value = this.txtapklink.Text;
}
catch (Exception)
{
appseting.Settings.Add("txtapklink", this.txtapklink.Text);
}
Configuration.Save();
}
示例5: Gadget
public Gadget()
{
InitializeComponent();
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Left = Int32.Parse(cfg.AppSettings.Settings["LocationX"].Value);
Top = Int32.Parse(cfg.AppSettings.Settings["LocationY"].Value);
Width = Int32.Parse(cfg.AppSettings.Settings["Width"].Value);
Height = Int32.Parse(cfg.AppSettings.Settings["Height"].Value);
string symbols = cfg.AppSettings.Settings["Symbols"].Value;
if (!string.IsNullOrWhiteSpace(symbols))
{
string[] arr = symbols.Split(new char[] { ';' });
cbSymbols.ItemsSource = arr;
}
SourceInitialized += new EventHandler(Gadjet_SourceInitialized);
int defaultCardRank = Int32.Parse(cfg.AppSettings.Settings["DefaultRank"].Value);
if (defaultCardRank < 0) defaultCardRank = 10;
presenter = new CardStackPresenter(this, defaultCardRank);
presenter.NextCard();
}
示例6: CrearArchivoConfig
private static void CrearArchivoConfig()
{
XmlTextWriter.Create(Assembly.GetExecutingAssembly().Location + ".config");
_config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
_config.Save();
}
示例7: AddinSettings
/// <summary>
/// Merge default settings (install DLLs) with current settings (user.config)
/// Read settings from %APPDATA%\ho\ho_tools\user.config
/// </summary>
public AddinSettings()
{
Configuration roamingConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
//the roamingConfig now get a path such as C:\Users\<user>\AppData\Roaming\Sparx_Systems_Pty_Ltd\DefaultDomain_Path_2epjiwj3etsq5yyljkyqqi2yc4elkrkf\9,_2,_0,_921\user.config
// which I don't like. So we move up three directories and then add a directory for the EA Navigator so that we get
// C:\Users\<user>\AppData\Roaming\GeertBellekens\EANavigator\user.config
string configFileName = System.IO.Path.GetFileName(roamingConfig.FilePath);
string configDirectory = System.IO.Directory.GetParent(roamingConfig.FilePath).Parent.Parent.Parent.FullName;
string newConfigFilePath = configDirectory + @"\ho\ho_Tools\" + configFileName;
// Map the roaming configuration file. This
// enables the application to access
// the configuration file using the
// System.Configuration.Configuration class
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = newConfigFilePath;
// Get the mapped configuration file.
currentConfig = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
//merge the default settings
this.mergeDefaultSettings();
this.shortcutsSearch = getShortcutsSearch();
this.shortcutsServices = getShortcutsServices();
this.globalShortcutsService = getGlobalShortcutsService();
this.globalShortcutsSearch = getGlobalShortcutsSearch();
getConnector(_logicalConnectors);
getConnector(_activityConnectors);
getAllServices();
updateSearchesAndServices();
}
示例8: ConfigurationManager
public ConfigurationManager()
{
//_configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(exePath);
_configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
SetDefaultSettings();
}
示例9: getCurrentConfig
//private static string AppConfigPath()
//{
// return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileName);
//}
/// <summary>
/// 获取当前应用配置
/// </summary>
/// <returns></returns>
public Configuration getCurrentConfig(char AppType = EnumAppType.Web)
{
if (currentConfig==null){
currentConfig = UtilSystem.getCurrentConfig(AppType);
}
return currentConfig;
}
示例10: ConfigAppSettingsto
protected static Configuration ConfigAppSettingsto(string filename)
{
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = filename;
config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
return config;
}
示例11: FormUpdater
public FormUpdater(string patcherExecutable, string patcherArguments)
{
this.patcherExecutable = patcherExecutable;
this.patcherArguments = patcherArguments;
try
{
hyperConfigFile = ConfigurationManager.OpenExeConfiguration(patcherExecutable);
}
catch (Exception)
{
MessageBox.Show("Failed to load " + patcherExecutable + ".config file", "Selfupdater");
Environment.Exit(0);
}
hyperSettings = hyperConfigFile.AppSettings.Settings;
hyperFolder = new DirectoryInfo(Environment.CurrentDirectory);
InitializeComponent();
try
{
hyperVersion = Convert.ToUInt32(hyperSettings["hyperVersion"].Value);
patchesWebPath = new Uri(hyperSettings["patchesWebPath"].Value);
}
catch (Exception)
{
hyperVersion = 0;
}
MessageBox.Show("Updates are going to be installed now.", "Selfupdater");
InitUpdateProcess();
}
示例12: ConfigurationMap
public ConfigurationMap(Configuration file, IPluginSettings settings, bool autoLoad)
{
this.file = file;
this.settings = settings;
if (autoLoad)
Load();
}
示例13: ContentPathProvider
public ContentPathProvider(VirtualPathProvider baseProvider, Configuration.Configuration services)
{
_baseProvider = baseProvider;
_config = services;
_internalResources = new Dictionary<string, string>();
switch (_config.ViewEngineOptions.Type)
{
case Configuration.ViewEngineType.Razor:
_extension = ".cshtml";
break;
case Configuration.ViewEngineType.ASPX:
_extension = ".aspx";
break;
default:
throw new ArgumentException("Invalid ViewEngine Specified.");
}
Action<string> addResource = (file) =>
_internalResources.Add(file + _extension, string.Format("Meek.Content.{0}.{1}{2}", _config.ViewEngineOptions.Type.ToString(), file, _extension));
addResource("Manage");
addResource("CreatePartial");
addResource("List");
addResource("BrowseFiles");
addResource("UploadFileSuccess");
}
示例14: SecureSettings
static SecureSettings()
{
if (System.Web.HttpContext.Current != null)
_config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
else
_config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
}
示例15: BaseTest
public BaseTest()
{
var configMap = new ExeConfigurationFileMap {ExeConfigFilename = "MySettings.config"};
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
if (config.HasFile)
_config = config;
}