当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.Load方法代码示例

本文整理汇总了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";
        }
开发者ID:porter1130,项目名称:WP8-DEMO,代码行数:18,代码来源:MainWindowViewModel.cs

示例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);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:38,代码来源:mconfig.cs

示例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;
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:70,代码来源:ConfigurationInclude.cs

示例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);
        }
开发者ID:HurricaneEntertainment,项目名称:DevProLauncher,代码行数:63,代码来源:Program.cs

示例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);
            }
        }
开发者ID:Sky9,项目名称:DevProLauncher,代码行数:95,代码来源:Program.cs


注:本文中的Configuration.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。