本文整理汇总了C#中Program.ParseProgramArgs方法的典型用法代码示例。如果您正苦于以下问题:C# Program.ParseProgramArgs方法的具体用法?C# Program.ParseProgramArgs怎么用?C# Program.ParseProgramArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program.ParseProgramArgs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
var ut = string.Empty;
var p = new Program(args);
try
{
p.StartConsole();
if (p.PrintHelp()) return;
p.PrintToConsole("New console started!");
p.ParseProgramArgs();
JavaTools.StanfordPostTaggerModels = Cfg.AppSettings["NoFuture.JavaTools.StanfordPostTaggerModels"];
if (string.IsNullOrWhiteSpace(JavaTools.StanfordPostTaggerModels) ||
!Directory.Exists(JavaTools.StanfordPostTaggerModels))
throw new ItsDeadJim("The Stanford Post Tagger Models are not assigned in the config file");
p.PrintToConsole($"models @ {JavaTools.StanfordPostTaggerModels}");
//open ports
p.LaunchListeners();
//park main
for (;;) //ever
{
ut = Console.ReadLine();
if (string.IsNullOrWhiteSpace(ut))
continue;
ut = ut.Trim();
if (string.Equals(ut, "exit", StringComparison.OrdinalIgnoreCase))
break;
if (string.Equals(ut, "-help", StringComparison.OrdinalIgnoreCase) ||
string.Equals(ut, "-h", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(p.GetHelpText());
}
}
}
catch (Exception ex)
{
p.PrintToConsole(ex);
}
if (String.IsNullOrWhiteSpace(ut) || !ut.StartsWith("exit"))
{
Console.ReadKey();
}
Environment.Exit(0);
}
示例2: Main
public static void Main(string[] args)
{
var p = new Program(args);
try
{
//get and test the cmd line arg key\values
p.StartConsole();
if (p.PrintHelp()) return;
p.ParseProgramArgs();
using (var conn = new SqlConnection(p.ConnectionString))
{
Console.WriteLine([email protected]"{p.MyProcMetadata.ProcName}");
conn.Open();
using (var cmd = conn.CreateCommand())
{
using (var da = new SqlDataAdapter(cmd))
{
var ds = new DataSet(p.MyProcMetadata.ProcName);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
//can be controlled from app.config
cmd.CommandTimeout = ConfigTimeout;
//assigns random values to (hopefully) avoid timeouts
p.MyProcMetadata.AssignSpParams(cmd.Parameters);
cmd.CommandText = p.MyProcMetadata.ProcName;
var processMsg = new InvokeStoredProcExeMessage { StoredProcName = p.MyProcMetadata.ProcName };
try
{
da.Fill(ds);
if (ds.Tables.Count <= 0)
processMsg.State = InvokeStoredProcExeState.NoDsReturned;
else if (ds.Tables.Count > 1)
processMsg.State = InvokeStoredProcExeState.MultiTableDs;
}
catch (Exception ex)
{
if (ex.Message.StartsWith("Timeout expired."))
processMsg.State = InvokeStoredProcExeState.TimedOut;
else if (ex.Message.StartsWith("Invalid ") || ex.Message.StartsWith("Incorrect syntax"))
{
processMsg.State = InvokeStoredProcExeState.BadSyntax;
Settings.WriteToStoredProcLog(ex, string.Format("bad syntax"));
}
else
{
processMsg.State = InvokeStoredProcExeState.OtherError;
Settings.WriteToStoredProcLog(ex, string.Format("invoke of da.Fill got this unexpected error."));
}
}
var xsdOutput = p.MyProcMetadata.XsdFilePath;
if (processMsg.State != InvokeStoredProcExeState.BadSyntax &&
processMsg.State != InvokeStoredProcExeState.TimedOut &&
processMsg.State != InvokeStoredProcExeState.OtherError &&
processMsg.State != InvokeStoredProcExeState.NoDsReturned)
{
//dump the returned dataset schema to file
ds.WriteXmlSchema(xsdOutput);
}
if(conn.State == ConnectionState.Open)
conn.Close();
if (!p.SendSocketMessages) return;
//once its on the disk then send a message to the manager
using (var com = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP))
{
Settings.WriteToStoredProcLog($"Sent from process '{processMsg}'");
com.Connect(new IPEndPoint(IPAddress.Loopback, InvokeStoredProcManager.SOCKET_COMM_PORT));
com.Send(Encoding.UTF8.GetBytes(processMsg.ToString()));
com.Close();
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
Settings.WriteToStoredProcLog(ex, "Error while executing NoFuture.Hbm.InvokeStoredProc.exe");
}
Thread.Sleep(NfConfig.ThreadSleepTime);//slight pause
}
示例3: Main
public static void Main(string[] args)
{
var p = new Program(args);
try
{
p.StartConsole();
if (p.PrintHelp())
return;
p.ParseProgramArgs();
//either perform single file op
if (p.MyFileParameters.FileCommand != InvokeKind.HostSjcl)
{
p.PerformFileCipher();
return;
}
//or host SJCL.js
p.HostSjcl();
}
catch (Exception ex)
{
p.PrintToConsole("CRITICAL ERROR");
p.PrintToConsole(ex);
}
p.PrintToConsole("press any key to exit...");
var noop = Console.ReadKey();
}