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


C# RavenConfiguration.LoadFrom方法代码示例

本文整理汇总了C#中Raven.Database.Config.RavenConfiguration.LoadFrom方法的典型用法代码示例。如果您正苦于以下问题:C# RavenConfiguration.LoadFrom方法的具体用法?C# RavenConfiguration.LoadFrom怎么用?C# RavenConfiguration.LoadFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Database.Config.RavenConfiguration的用法示例。


在下文中一共展示了RavenConfiguration.LoadFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InteractiveRun

		private static void InteractiveRun(string[] args)
		{
			string backupLocation = null;
			string restoreLocation = null;
			Action actionToTake = null;
			bool launchBrowser = false;
			var ravenConfiguration = new RavenConfiguration();

			OptionSet optionSet = null;
			optionSet = new OptionSet
			{
				{"set={==}", "The configuration {0:option} to set to the specified {1:value}" , (key, value) =>
				{
					ravenConfiguration.Settings[key] = value;
					ravenConfiguration.Initialize();
				}},
				{"config=", "The config {0:file} to use", path => ravenConfiguration.LoadFrom(path)},
				{"install", "Installs the RavenDB service", key => actionToTake= () => AdminRequired(InstallAndStart, key)},
				{"service-name=", "The {0:service name} to use when installing or uninstalling the service, default to RavenDB", name => ProjectInstaller.SERVICE_NAME = name},
				{"uninstall", "Uninstalls the RavenDB service", key => actionToTake= () => AdminRequired(EnsureStoppedAndUninstall, key)},
				{"start", "Starts the RavenDB service", key => actionToTake= () => AdminRequired(StartService, key)},
				{"restart", "Restarts the RavenDB service", key => actionToTake= () => AdminRequired(RestartService, key)},
				{"stop", "Stops the RavenDB service", key => actionToTake= () => AdminRequired(StopService, key)},
				{"ram", "Run RavenDB in RAM only", key =>
				{
					ravenConfiguration.Settings["Raven/RunInMemory"] = "true";
					ravenConfiguration.RunInMemory = true;
					actionToTake = () => RunInDebugMode(AnonymousUserAccessMode.All, ravenConfiguration, launchBrowser);		
				}},
				{"debug", "Runs RavenDB in debug mode", key => actionToTake = () => RunInDebugMode(null, ravenConfiguration, launchBrowser)},
				{"browser|launchbrowser", "After the server starts, launches the browser", key => launchBrowser = true},
				{"help", "Help about the command line interface", key =>
				{
					actionToTake = () => PrintUsage(optionSet);
				}},
				{"config-help", "Help about configuration options", key=>
				{
					actionToTake = PrintConfig;
				}},
				{"restore", 
					"Restores a RavenDB database from backup",
					key => actionToTake = () =>
					{
						if(backupLocation == null || restoreLocation == null)
						{
							throw new OptionException("when using restore, source and destination must be specified", "restore");
						}
						RunRestoreOperation(backupLocation, restoreLocation);
					}},
				{"dest=|destination=", "The {0:path} of the new new database", value => restoreLocation = value},
				{"src=|source=", "The {0:path} of the backup", value => backupLocation = value},
				{"encrypt-self-config", "Encrypt the RavenDB configuration file", file =>
						{
							actionToTake = () => ProtectConfiguration(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
				        }},
				{"encrypt-config=", "Encrypt the specified {0:configuration file}", file =>
						{
							actionToTake = () => ProtectConfiguration(file);
				        }},
				{"decrypt-self-config", "Decrypt the RavenDB configuration file", file =>
						{
							actionToTake = () => UnprotectConfiguration(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
				        }},
				{"decrypt-config=", "Decrypt the specified {0:configuration file}", file =>
						{
							actionToTake = () => UnprotectConfiguration(file);
				        }}
			};


			try
			{
				if (args.Length == 0) // we default to executing in debug mode 
					args = new[] { "--debug" };

				optionSet.Parse(args);
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				PrintUsage(optionSet);
				return;
			}

			if (actionToTake == null)
				actionToTake = () => RunInDebugMode(null, ravenConfiguration, launchBrowser);

			actionToTake();

		}
开发者ID:denno-secqtinstien,项目名称:ravendb,代码行数:90,代码来源:Program.cs

示例2: InteractiveRun

        private static void InteractiveRun(string[] args)
        {
        	string backupLocation = null;
        	string restoreLocation = null;
        	Action actionToTake = null;
        	bool launchBrowser = false;
			var ravenConfiguration = new RavenConfiguration();

        	OptionSet optionSet = null;
        	optionSet = new OptionSet
        	{
				{"config=", "The config section to use", path => ravenConfiguration.LoadFrom(path)},
        		{"install", "Installs the RavenDB service", key => actionToTake= () => AdminRequired(InstallAndStart, key)},
        		{"uninstall", "Uninstalls the RavenDB service", key => actionToTake= () => AdminRequired(EnsureStoppedAndUninstall, key)},
        		{"start", "Starts the RavenDB servce", key => actionToTake= () => AdminRequired(StartService, key)},
        		{"restart", "Restarts the RavenDB service", key => actionToTake= () => AdminRequired(RestartService, key)},
        		{"stop", "Stops the RavenDB service", key => actionToTake= () => AdminRequired(StopService, key)},
        		{"ram", "Run RavenDB in RAM only", key =>
        		{
        			ravenConfiguration.Settings["Raven/RunInMemory"] = "true";
        			ravenConfiguration.RunInMemory = true;
					actionToTake = () => RunInDebugMode(AnonymousUserAccessMode.All, ravenConfiguration, launchBrowser);		
        		}},
        		{"debug", "Runs RavenDB in debug mode", key => actionToTake = () => RunInDebugMode(null, ravenConfiguration, launchBrowser)},
				{"browser|launchbrowser", "After the server starts, launches the browser", key => launchBrowser = true},
        		{"help", "Help about the command line interface", key =>
        		{
					actionToTake = () => PrintUsage(optionSet);
        		}},
        		{"restore", 
        			"Restores a RavenDB database from backup",
        			key => actionToTake = () =>
        			{
        				if(backupLocation == null || restoreLocation == null)
        				{
        					throw new OptionException("when using restore, source and destination must be specified", "restore");
        				}
        				RunRestoreOperation(backupLocation, restoreLocation);
        			}},
        		{"dest=|destination=", "The {0:path} of the new new database", value => restoreLocation = value},
        		{"src=|source=", "The {0:path} of the backup", value => backupLocation = value},
        	};


        	try
        	{
				if(args.Length == 0) // we default to executing in debug mode 
					args = new[]{"--debug"};

        		optionSet.Parse(args);
        	}
        	catch (Exception e)
        	{
        		Console.WriteLine(e.Message);
        		PrintUsage(optionSet);
        		return;
        	}

			if (actionToTake == null)
				actionToTake = () => PrintUsage(optionSet);
			
			actionToTake();
			
        }
开发者ID:wbinford,项目名称:ravendb,代码行数:64,代码来源:Program.cs


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