本文整理汇总了C#中System.CommandLine.PrintUsage方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLine.PrintUsage方法的具体用法?C# CommandLine.PrintUsage怎么用?C# CommandLine.PrintUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CommandLine
的用法示例。
在下文中一共展示了CommandLine.PrintUsage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunApplication
public void RunApplication(string[] args)
{
var commandLine = new CommandLine();
try
{
commandLine.Parse(args);
}
catch (Exception e)
{
Platform.Log(LogLevel.Info, e);
Console.WriteLine(e.Message);
commandLine.PrintUsage(Console.Out);
Environment.Exit(-1);
}
try
{
DicomServer.DicomServer.UpdateConfiguration(new DicomServerConfiguration
{
HostName = commandLine.HostName,
AETitle = commandLine.AETitle,
Port = commandLine.Port
});
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Platform.Log(LogLevel.Warn, e);
Environment.Exit(-1);
}
try
{
if (!String.IsNullOrEmpty(commandLine.FileStoreDirectory))
StudyStore.UpdateConfiguration(new StorageConfiguration
{
FileStoreDirectory = commandLine.FileStoreDirectory,
MinimumFreeSpacePercent =
commandLine.MinimumFreeSpacePercent != null
? double.Parse(commandLine.MinimumFreeSpacePercent)
: StorageConfiguration.AutoMinimumFreeSpace
});
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Platform.Log(LogLevel.Warn, e);
Environment.Exit(-1);
}
}
示例2: RunApplication
public void RunApplication(string[] args)
{
CommandLine cmdLine = new CommandLine();
try
{
cmdLine.Parse(args);
if (cmdLine.Switches.ContainsKey("storedprocedures") && cmdLine.Switches["storedprocedures"])
{
Console.WriteLine("Upgrading the stored procedures.");
if (!RunEmbeddedScript("ClearCanvas.ImageServer.Model.SqlServer.Scripts.ImageServerStoredProcedures.sql"))
Environment.ExitCode = -1;
else
Environment.ExitCode = 0;
}
if (cmdLine.Switches.ContainsKey("defaultdata") && cmdLine.Switches["defaultdata"])
{
Console.WriteLine("Upgrading the stored procedures.");
if (!RunEmbeddedScript("ClearCanvas.ImageServer.Model.SqlServer.Scripts.ImageServerDefaultData.sql"))
Environment.ExitCode = -1;
else
Environment.ExitCode = 0;
}
foreach (string script in cmdLine.Positional)
{
if (!RunScript(script))
{
Console.WriteLine("Upgrading to execute script: {0}", script);
Environment.ExitCode = -1;
return;
}
}
}
catch (CommandLineException e)
{
Console.WriteLine(e.Message);
cmdLine.PrintUsage(Console.Out);
Environment.ExitCode = -1;
}
catch (Exception e)
{
Console.WriteLine("Unexpected exception when executing script: {0}", e.Message);
Environment.ExitCode = -1;
}
}
示例3: RunApplication
public void RunApplication(string[] args)
{
var cmdLine = new CommandLine();
try
{
cmdLine.Parse(args);
var persistentStoreVersion = LoadPersistentStoreVersion();
var assemblyVersion = LoadAssemblyVersion();
if (cmdLine.Switches.ContainsKey("check") && cmdLine.Switches["check"])
{
CheckPersistentStoreStatus(persistentStoreVersion, assemblyVersion);
return;
}
Console.WriteLine("The current database version is {0} and assembly version is {1}",
persistentStoreVersion.ToString(4),
assemblyVersion.ToString(4));
if (persistentStoreVersion.Equals(assemblyVersion))
{
Console.WriteLine("Database version is up-to-date.");
Environment.ExitCode = 0;
return;
}
if (!UpdatePersistentStore(persistentStoreVersion, assemblyVersion))
Environment.ExitCode = -1;
else
{
Environment.ExitCode = 0;
}
}
catch (CommandLineException e)
{
Console.WriteLine(e.Message);
cmdLine.PrintUsage(Console.Out);
Environment.ExitCode = -1;
}
catch (Exception e)
{
Console.WriteLine("Unexpected exception when upgrading database: {0}", e.Message);
Environment.ExitCode = -1;
}
}
示例4: RunApplication
public void RunApplication(string[] args)
{
var cmd = new CommandLine();
try
{
cmd.Parse(args);
}
catch (Exception)
{
cmd.PrintUsage(Console.Out);
Environment.Exit(-1);
}
//Hack to redirect local shared settings to a different exe's config file.
ExtendedLocalFileSettingsProvider.ExeConfigFileName = cmd.Target;
foreach (var settingsClass in _applicationSettingsClasses)
{
var settingsType = Type.GetType(settingsClass);
SettingsMigrator.MigrateSharedSettings(settingsType, cmd.Source);
}
try
{
if (!String.IsNullOrEmpty(cmd.DicomServersFileName) && File.Exists(cmd.DicomServersFileName))
{
var existingServerTree = new ServerTree.ServerTree();
if (existingServerTree.RootServerGroup.GetAllServers().Count == 0)
{
//Settings NOT from an old xml file were just migrated, so
//if there's still no servers defined, import from old xml file.
var serverTree = new ServerTree.ServerTree(cmd.DicomServersFileName);
serverTree.Save();
}
}
}
catch (Exception e)
{
Platform.Log(LogLevel.Warn, e, "Failed to import legacy server tree '{0}'.", cmd.DicomServersFileName);
}
}