本文整理汇总了C#中ServerConnection.RetrieveServerName方法的典型用法代码示例。如果您正苦于以下问题:C# ServerConnection.RetrieveServerName方法的具体用法?C# ServerConnection.RetrieveServerName怎么用?C# ServerConnection.RetrieveServerName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.RetrieveServerName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var connection = new ServerConnection(args[0]);
var exit = false;
WriteToConsole(ConsoleColor.White, "CruiseControl.NET: Interactive Console");
WriteToConsole(ConsoleColor.White, new string('=', 40));
WriteToConsole(ConsoleColor.DarkGray, "Retrieving server name from '" + args[0] + "'...");
string fullUrn;
try
{
fullUrn = connection.RetrieveServerName();
}
catch (Exception error)
{
WriteToConsole(ConsoleColor.Red, "...unable to retrieve server name: " + error.Message);
return;
}
WriteToConsole(ConsoleColor.DarkGray, "...server name is '{0}'", fullUrn);
var shortUrn = fullUrn.Substring(10);
while (!exit)
{
Console.Write(shortUrn + ">");
var command = ReadFromConsole();
switch (command.Name)
{
case "exit":
case "quit":
exit = true;
break;
case "ping":
case "~":
RunPingCommand(connection);
break;
case "query":
case "?":
RunQueryCommand(connection, fullUrn);
break;
case "invoke":
case ".":
RunInvokeCommand(connection, fullUrn, command.Arguments);
break;
case "up":
case "-":
if (shortUrn.Contains(":"))
{
shortUrn = shortUrn.Substring(0, shortUrn.LastIndexOf(':'));
fullUrn = fullUrn.Substring(0, fullUrn.LastIndexOf(':'));
}
break;
case "down":
case "+":
if (command.Arguments.Length > 0)
{
fullUrn += ":" + command.Arguments[0];
shortUrn += ":" + command.Arguments[0];
}
break;
default:
WriteToConsole(ConsoleColor.Gray, "!! Unknown command: " + command.Name + " !!");
break;
}
}
}