本文整理汇总了C#中System.Configuration.Configuration类的典型用法代码示例。如果您正苦于以下问题:C# Configuration类的具体用法?C# Configuration怎么用?C# Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于System.Configuration命名空间,在下文中一共展示了Configuration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jamescourtney,项目名称:mono,代码行数:7,代码来源:SerializationSectionGroup.cs
示例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"));
}
开发者ID:jltrem,项目名称:DDay.Update,代码行数:32,代码来源:OptionsForm.cs
示例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.");
}
}
}
开发者ID:akrisiun,项目名称:git-dot-aspx,代码行数:29,代码来源:RoutingModule.cs
示例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();
}
开发者ID:lijiajin1987,项目名称:OfficialWebsite,代码行数:25,代码来源:Home.aspx.cs
示例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();
}
开发者ID:paveltimofeev,项目名称:Wordcards,代码行数:25,代码来源:Gadget.xaml.cs
示例6: CrearArchivoConfig
private static void CrearArchivoConfig()
{
XmlTextWriter.Create(Assembly.GetExecutingAssembly().Location + ".config");
_config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
_config.Save();
}
开发者ID:Maharba,项目名称:YACM,代码行数:7,代码来源:ConfigAcciones.cs
示例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();
}
开发者ID:Helmut-Ortmann,项目名称:EnterpriseArchitect_hoTools,代码行数:35,代码来源:Settings.cs
示例8: ConfigurationManager
public ConfigurationManager()
{
//_configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(exePath);
_configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
SetDefaultSettings();
}
开发者ID:Sagittarius10k,项目名称:MigrationTool,代码行数:7,代码来源:ConfigurationManager.cs
示例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;
}
开发者ID:skygreen2001,项目名称:Betterlife.Net,代码行数:16,代码来源:AppConfig.cs
示例10: ConfigAppSettingsto
protected static Configuration ConfigAppSettingsto(string filename)
{
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = filename;
config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
return config;
}
开发者ID:Crazye,项目名称:VPRR,代码行数:7,代码来源:ConfigAppSettings.cs
示例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();
}
开发者ID:BenYao,项目名称:Hyperbyte-Patcher,代码行数:29,代码来源:FormUpdater.cs
示例12: ConfigurationMap
public ConfigurationMap(Configuration file, IPluginSettings settings, bool autoLoad)
{
this.file = file;
this.settings = settings;
if (autoLoad)
Load();
}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:7,代码来源:ConfigurationMap.cs
示例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");
}
开发者ID:GStore,项目名称:Meek,代码行数:27,代码来源:ContentPathProvider.cs
示例14: SecureSettings
static SecureSettings()
{
if (System.Web.HttpContext.Current != null)
_config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
else
_config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
}
开发者ID:kdcllc,项目名称:KDCLLCWeb,代码行数:7,代码来源:SecureSettings.cs
示例15: BaseTest
public BaseTest()
{
var configMap = new ExeConfigurationFileMap {ExeConfigFilename = "MySettings.config"};
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
if (config.HasFile)
_config = config;
}
开发者ID:kernicus,项目名称:usergrid-.net-sdk,代码行数:7,代码来源:BaseTest.cs
示例16: Load
private bool Load(string file)
{
var map = new ExeConfigurationFileMap { ExeConfigFilename = file };
config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
var xml = new XmlDocument();
using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
xml.Load(stream);
//var cfgSections = xml.GetElementsByTagName("configSections");
//if (cfgSections.Count > 0)
//{
// foreach (XmlNode node in cfgSections[0].ChildNodes)
// {
// var type = System.Activator.CreateInstance(
// Type.GetType(node.Attributes["type"].Value))
// as IConfigurationSectionHandler;
// if (type == null) continue;
// customSections.Add(node.Attributes["name"].Value, type);
// }
//}
return config.HasFile;
}
开发者ID:stevesloka,项目名称:bvcms,代码行数:27,代码来源:ConfigurationProxy.cs
示例17: Settings
public Settings()
{
try
{
Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Msg.Log("Loading config file \"" + Path.GetFileName(Config.FilePath) + "\".");
}
catch (ConfigurationErrorsException)
{
Msg.Log ("Error reading config file!");
Msg.MsgBox("Error reading config file!");
return;
}
//Create keys with default values in config file if they don't exist yet.
this.Add("GameDir", null);
this.Add("ModConfig", "Default");
this.Add("ModConfigList", "Default");
this.Add("ModConfig_Default", "");
this.Add("SkinConfig", "Default");
this.Add("SkinConfigList", "Default");
this.Add("SkinConfig_Default", "");
this.Add("ModsReplaceDefaultSkins", "True");
this.Add("ModConfigAutosave", "True");
this.Add("SkinConfigAutosave", "True");
this.Save(); //Save config to disk.
}
开发者ID:Worst-vd-plas,项目名称:Patchlunky,代码行数:28,代码来源:Settings.cs
示例18: NamedPipeMessageBus
private NamedPipeMessageBus(Configuration configuration)
{
LoadConfiguration(configuration);
_readThread = new Thread(ReadData);
_readThread.Start();
}
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:7,代码来源:NamedPipeMessageBus.cs
示例19: GetConfiguration
/// <summary>
/// This method will retrieve the configuration settings.
/// </summary>
private void GetConfiguration()
{
try
{
m_config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
if (m_config.Sections["TracePreferences"] == null)
{
m_settings = new TracePreferences();
m_config.Sections.Add("TracePreferences", m_settings);
m_config.Save(ConfigurationSaveMode.Full);
}
else
m_settings = (TracePreferences)m_config.GetSection("TracePreferences");
}
catch (InvalidCastException e)
{
System.Diagnostics.Trace.WriteLine("Preference Error - " + e.Message, "MainForm.GetConfiguration");
MessageBoxOptions options = 0;
MessageBox.Show(Properties.Resources.PREF_NOTLOADED, Properties.Resources.PREF_CAPTION,
MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, options);
m_settings = new TracePreferences();
}
catch (ArgumentException e)
{
System.Diagnostics.Trace.WriteLine("Argument Error - " + e.Message, "MainForm.GetConfiguration");
throw;
}
catch (ConfigurationErrorsException e)
{
System.Diagnostics.Trace.WriteLine("Configuration Error - " + e.Message, "MainForm.GetConfiguration");
throw;
}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:36,代码来源:StartupSettings.cs
示例20: ExplorerSettings
static ExplorerSettings()
{
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
try
{
/*if (config.AppSettings.Settings["LoggerMode"].Value == "info")
logger = LoggerMode.info;
else if (config.AppSettings.Settings["LoggerMode"].Value == "debug")
logger = LoggerMode.debug;
else throw new Exception("LoggerMode is set improperly.");*/
loggingDirectory = config.AppSettings.Settings["LoggingDirectory"].Value;
storageDirectory = config.AppSettings.Settings["StorageDirectory"].Value;
//connectionString = config.ConnectionStrings.ConnectionStrings[config.AppSettings.Settings["SQLProvider"].Value].ConnectionString;
tracingDirectory = config.AppSettings.Settings["TracingDirectory"].Value;
workingMode = (ManagerType)Enum.Parse(typeof(ManagerType),
config.AppSettings.Settings["WorkingMode"].Value);
staticGenerationDirectory = config.AppSettings.Settings["StaticGenerationDirectory"].Value;
matrixConvertionToolDirectory = config.AppSettings.Settings["MatrixConvertionToolDirectory"].Value;
modelCheckingToolDirectory = config.AppSettings.Settings["ModelCheckingToolDirectory"].Value;
}
catch
{
throw new CoreException("The structure of Configuration file is not correct.");
}
}
开发者ID:aramazhari,项目名称:complexnetwork,代码行数:27,代码来源:ExplorerSettings.cs
注:本文中的System.Configuration.Configuration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论