本文整理汇总了C#中Configuration.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Load方法的具体用法?C# Configuration.Load怎么用?C# Configuration.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.Load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindowViewModel
public MainWindowViewModel()
{
//create all required objects
_phoneController = new PhoneControllerServer();
_phoneController.Error += _phoneController_Error;
_phoneController.StateChanged += _phoneController_StateChanged;
_phoneController.DataMessageReceived += _phoneController_DataMessageReceived;
_inputEmulator = new InputEmulator();
// make sure to load the previous configuration
// so the user does not need to set all desired options every time
// the application starts
Configuration = new Configuration();
Configuration.Load();
Status = "Started";
}
示例2: Main
static int Main (string[] args)
{
MConfigOptions options = new MConfigOptions ();
options.Parse (args);
if (!String.IsNullOrEmpty (options.ConfigFile))
configPaths [3] = options.ConfigFile;
Configuration config = new Configuration ();
try {
config.Load (configPaths);
} catch (Exception ex) {
PrintException (ex, "Failed to load configuration files:");
return 1;
}
string[] commandArguments = options.PlainArguments;
if (commandArguments == null || commandArguments.Length == 0) {
options.UsageCommands ();
DisplayList ("Default config files:", config.DefaultConfigFiles);
Console.WriteLine ();
DisplayList ("Available features:", config.Features);
return 1;
}
HandleCommand commandHandler = FindCommandHandler (commandArguments [0]);
if (commandHandler == null) {
Console.Error.WriteLine ("Unknown command '{0}'", commandArguments [0]);
return 1;
}
IDefaultConfigFileContainer[] containers = config.GetHandlersForInterface <IDefaultConfigFileContainer> ();
if (containers != null && containers.Length > 0)
foreach (IDefaultConfigFileContainer c in containers)
c.OverwriteFile += new OverwriteFileEventHandler (OnOverwriteFile);
return commandHandler (options, config);
}
示例3: ParsesInclude
/// <summary>
/// Parses the included file.
/// </summary>
/// <param name="resolver">The resolver to resolve the include file.</param>
/// <returns>The Dictionary of ConfigurationModule.</returns>
public Dictionary<string, ConfigurationModule> ParsesInclude(Configuration.ConfigurationResolver resolver)
{
Configuration config = new Configuration();
config.ConfigurationResolve += resolver;
config.Load(Source);
Dictionary<string, ConfigurationModule> modules = config.GetAllModules();
// Overwrite the inputs in the included file according to the inputs.
foreach (ConfigurationInput item in Inputs.Values)
{
if (!ConfigurationReference.IsReference(item.Name))
{
throw new ConfigurationException(
Helper.NeutralFormat("Input \"{0}\" in include element isn't reference", item.Name));
}
ConfigurationReference reference = new ConfigurationReference();
reference.Parse(item.Name);
if (!modules.ContainsKey(reference.Module))
{
throw new ConfigurationException(
Helper.NeutralFormat(
"No such module name \"{0}\" found in include file, one of below expected - {1}", reference.Module,
string.Join(",", modules.Keys.ToArray())));
}
if (reference.Name == ConfigurationModule.SkipAttribute)
{
// Overwrite the skip attribute.
modules[reference.Module].Skip = bool.Parse(item.Value);
}
else if (reference.Name == ConfigurationModule.KeepIntermediateDataAttribute)
{
// Overwrite the keep intermediate data attribute.
modules[reference.Module].KeepIntermediateData = bool.Parse(item.Value);
}
else
{
if (modules[reference.Module].Inputs.ContainsKey(reference.Name))
{
// Overwrite the exist input.
modules[reference.Module].Inputs[reference.Name].Value = item.Value;
}
else
{
// Create a new input.
ConfigurationInput input = new ConfigurationInput
{
Name = reference.Name,
Value = item.Value
};
modules[reference.Module].Inputs.Add(input.Name, input);
}
modules[reference.Module].Inputs[reference.Name].IsCdataSection = item.IsCdataSection;
}
}
return modules;
}
示例4: Main
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
if (LauncherHelper.checkInstance() != null)
if (MessageBox.Show(lang.pmsbProgRun) == DialogResult.OK)
return;
Config = new Configuration();
Config.Load(Program.ConfigurationFilename);
lang = new Language();
lang.Load(Config.language + ".conf");
UserInfo = new UserData();
ServerConnection = new NetClient();
if (!Config.DebugMode)
{
if (CheckUpdates())
return;
CheckServerInfo();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);
if(!ServerConnection.Connect(Config.ServerAddress, Config.ServerPort))
{
MessageBox.Show(lang.pMsbErrorToServer);
}
if (Config.AutoLogin)
{
LoginService.Authenticate();
Thread.Sleep(2000);
}
if (UserInfo.Username == "" && UserInfo.LoginKey == "")
{
LoginWindow = new Login_frm(Config, ServerConnection, LoginService);
if (LoginWindow.ShowDialog() != DialogResult.OK)
{
return;
}
Thread.Sleep(2000);
}
if (!ServerConnection.IsConnected)
{
return;
}
if (UserInfo.Username != "" && UserInfo.LoginKey != "")
Application.Run(new Main_frm());
else
MessageBox.Show(lang.pMsbBadLog);
}
示例5: Main
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
foreach(string arg in args)
{
if (arg == "-r")
{
int timeout = 0;
while (LauncherHelper.checkInstance())
{
if (timeout == 3)
{
if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
{
return;
}
}
Thread.Sleep(500);
timeout++;
}
}
}
Config = new Configuration();
Config.Load(Program.ConfigurationFilename);
if (File.Exists("ygopro_vs.exe") && !File.Exists("devpro.dll"))
{
File.Copy("ygopro_vs.exe", "devpro.dll");
File.Delete("ygopro_vs.exe");
Config.GameExe = "devpro.dll";
Config.Save(ConfigurationFilename);
}
LanguageManager = new LanguageManager();
//LanguageManager.Save("English");
LanguageManager.Load(Config.Language);
if (LauncherHelper.checkInstance())
if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
return;
UserInfo = new UserData();
ServerConnection = new NetClient();
if (!Config.DebugMode)
{
if (CheckUpdates())
return;
CheckServerInfo();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);
if(!ServerConnection.Connect(Config.ServerAddress, Config.ServerPort))
{
MessageBox.Show(LanguageManager.Translation.pMsbErrorToServer);
}
if (Config.AutoLogin && Config.DefaultUsername.Length < 15)
{
LoginService.Authenticate();
Thread.Sleep(2000);
}
if (UserInfo.Username == "" && UserInfo.LoginKey == "")
{
LoginWindow = new Login_frm(Config, ServerConnection, LoginService);
if (LoginWindow.ShowDialog() != DialogResult.OK)
{
return;
}
}
if (!ServerConnection.IsConnected)
{
return;
}
if (UserInfo.Username != "" && UserInfo.LoginKey != "")
Application.Run(new Main_frm());
else
{
Config.AutoLogin = false;
Config.Save(ConfigurationFilename);
MessageBox.Show(LanguageManager.Translation.pMsbBadLog);
}
}