public void Given() { CmdLine.Init(new[] { "/uninstall" }); }
protected void Test_Call <T>(string[] args, bool expectedNonStatic, bool expectedStatic) where T : class { CmdLine <T> .Execute(args); Assert.AreEqual(expectedNonStatic, WasNonStaticMethodCalled, expectedNonStatic ? "Expected non-static method to be called but NO call was made" : "Expected non-static method NOT to be called but the call was made"); Assert.AreEqual(expectedStatic, WasStaticMethodCalled, expectedStatic ? "Expected static method to be called but NO call was made" : "Expected static method NOT to be called but the call was made"); }
public void Given() { CmdLine.Init(new[] { "/profile:testing" }); }
private void insert(int index, List <CmdLine> cmdLineList, bool isCopy) { if (cmdLineList == null || cmdLineList.Count <= 0) { return; } CmdLine cmdLine = null; listView1.BeginUpdate(); for (int i = 0; i < cmdLineList.Count; i++) { cmdLine = cmdLineList[i].Clone() as CmdLine; if (isCopy) { cmdLine.IdCode = cmdLineList[i].IdCode; } commandsModule.InsertCmdLine(index + i, cmdLine); insertListViewItem(index + i, cmdLine); } for (int i = 0; i < lastSelectedIndices.Count; i++) { if (lastSelectedIndices[i] >= index) { lastSelectedIndices[i] += cmdLineList.Count; } } resizeCmdColumnWidth(); listView1.EndUpdate(); updateLineNumbers(); }
private void OnZoomToExtents(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_ZoomFeatures"; CmdLine.ExecuteQuietCommand(cmdString); }
public override void Execute() { int numericWidth = CmdLine.GetIntSwitch("/W", 6); bool paddingWithZeros = CmdLine.GetBooleanSwitch("/Z"); char padChar; CheckIntRange(numericWidth, 0, int.MaxValue, "Numeric width", CmdLine.GetSwitchPos("/W")); if (paddingWithZeros) { padChar = '0'; } else { padChar = ' '; } Open(); try { int lineCount = Host.TextLineCount; WriteText(lineCount.ToString().PadLeft(numericWidth, padChar)); } finally { Close(); } }
private string GetArg(int argIndex, bool inString) { string tempStr; string methodName = "Pipe.GetArg"; if ((argIndex > -1) && (argIndex < CmdLine.ArgCount)) { // The argument index is in range. tempStr = CmdLine.GetArg(argIndex).Value.ToString(); if (CmdLine.GetArg(argIndex).Value is string) { // Quote the string: if (!inString) { tempStr = "'" + tempStr + "'"; } } LogWrite(methodName + ": Args[" + argIndex.ToString() + "] = \"" + tempStr + "\""); } else { // The argument index is out of range. throw new PipeWrenchCompileException("Placeholder index is out of range."); } return(tempStr); }
private void OnDeleteFeatureClass(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_DeleteFeatureClass"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnSelectByAttributes(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_SelectByAttribute"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnClearSelection(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_ClearSelected"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnOpenMapServiceLayerProperties(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".esri_MapServiceProperties "; CmdLine.ExecuteQuietCommand(cmdString); }
/// <summary> /// 更新一组命令行 /// </summary> /// <param name="cmdLineList"></param> private void update(Dictionary <int, CmdLine> cmdLineList, bool isSelected) { if (cmdLineList == null || cmdLineList.Count <= 0) { return; } listView1.BeginUpdate(); CmdLine cmdLine = null; foreach (int index in cmdLineList.Keys) { cmdLine = cmdLineList[index].Clone() as CmdLine; commandsModule.RemoveCmdLineAt(index); commandsModule.InsertCmdLine(index, cmdLine); var item = createItem(cmdLine); if (isSelected) { item.Selected = true; } else { item.Selected = false; } listView1.Items[index] = item; } resizeCmdColumnWidth(); listView1.EndUpdate(); }
static void Main(string[] args) { AppGuard.Invoke(() => CmdLine <Program> .Execute(args, new CmdLineConfig { ArgStartsWith = '-' })); AppGuard.DebugReadLine(); }
private void OnRefreshFeatureService(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".esri_Synchronize"; CmdLine.ExecuteQuietCommand(cmdString); }
/// <summary> /// 将命令 逆序 /// </summary> public List <CmdLine> ReverseCmdLines() { int count = this.CmdLineList.Count; cmdLinesReversed.Clear(); int preIndex = -1; for (int i = 0; i < count; i++) { CmdLine cmdLine = this.CmdLineList[i]; if (cmdLine is MarkCmdLine) { preIndex = i; cmdLinesReversed.Add(cmdLine); } else if (cmdLine is BadMarkCmdLine) { preIndex = i; cmdLinesReversed.Add(cmdLine); } else if (cmdLine is MeasureHeightCmdLine) { preIndex = i; cmdLinesReversed.Add(cmdLine); } } for (int i = this.CmdLineList.Count - 2; i > preIndex; i--) { CmdLine cmdLine = this.CmdLineList[i]; cmdLinesReversed.Add(cmdLine); } cmdLinesReversed.Add(this.CmdLineList[this.CmdLineList.Count - 1]); return(null); }
public static int Main(string[] args) { CmdLine cmd = new CmdLine(args); if (cmd.ArgNum < 1) { PrintUsage(); return(-1); } PoseSeq psq = new PoseSeq(); psq.Load(cmd.mArgs[0]); TextWriter tw = Console.Out; string outName = cmd.GetStringOpt("out", null); if (outName != null) { tw = Util.MakeTextFile(outName); } psq.WriteInfo(tw); if (outName != null) { tw.Close(); } return(0); }
protected void Execute(bool rotatingLeft) { int noOfChars = (int)CmdLine.GetArg(0).Value; CheckIntRange(noOfChars, 1, int.MaxValue, "No. of characters", CmdLine.GetArg(0).CharPos); Open(); try { while (!EndOfText) { string line = ReadLine(); if (line.Length > 0) { RotateStr(ref line, rotatingLeft, noOfChars); } WriteText(line); } } finally { Close(); } }
static void Main(string[] args) { if (args.Length == 0) { PrintProgramSummary(); Console.WriteLine("For additional help type: dotnet EnableCors.dll -help"); PrintDeveloperInfo(); return; } else if ((args.Length == 1 && CheckHelpParam(args[0]))) { Help(); return; } CmdLine cmd = new CmdLine(args); if (!CheckCmdlineValidity(cmd)) { return; } string accessKey = cmd[PARAM_ACCESS_KEY]; string secretKey = cmd[PARAM_SECRET_KEY]; string region = cmd[PARAM_REGION]; string apiID = cmd[PARAM_API_ID]; string inputFile = cmd[0]; CreateCORsEntries(inputFile, accessKey, secretKey, region, apiID); }
public override void Execute() { string breakChars = CmdLine.GetStrSwitch("/B", string.Empty); int jaggednessAllowed = CmdLine.GetIntSwitch("/J", 25); int charPos = (int)CmdLine.GetArg(0).Value; CheckIntRange(charPos, 1, int.MaxValue, "Char. position", CmdLine.GetArg(0).CharPos); CheckIntRange(jaggednessAllowed, 0, 100, "% jaggedness", CmdLine.GetSwitchPos("/J")); Open(); try { while (!EndOfText) { string line = ReadLine(); WriteText(Wrap(line, charPos, breakChars, jaggednessAllowed)); } } finally { Close(); } }
private void OnOpenFeatureClassProperties(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".esri_FeatureClassProperties "; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnSelectAllClicked(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_SelectFeatures"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnExtractFeatureService(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_DisconnectFeatureService"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnOpenAttributeTable(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_Table"; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnClickMapExport(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".ESRI_ExportMap "; CmdLine.ExecuteQuietCommand(cmdString); }
private void OnOpenTableSelected(object sender, RoutedEventArgs e) { CmdLine.CancelActiveCommand(); string cmdString = ".esri_TableSelected"; CmdLine.ExecuteQuietCommand(cmdString); }
/// <summary> /// 禁用/取消禁用选中命令 /// </summary> public void Disable() { if (!canOperate()) { return; } var selectedIndexs = listView1.SelectedIndices; // END 命令不可以DISABLE if (commandsModule.CmdLineList[selectedIndexs[selectedIndexs.Count - 1]] is EndCmdLine) { //MessageBox.Show("END can not be disabled."); MessageBox.Show("END指令不可以禁用."); return; } Dictionary <int, CmdLine> cmdLineList = new Dictionary <int, CmdLine>(); CmdLine cmdLine = null; foreach (int index in selectedIndexs) { cmdLine = commandsModule.CmdLineList[index]; cmdLine.Enabled = !cmdLine.Enabled; cmdLineList.Add(index, cmdLine); } update(cmdLineList, true); this.UpdateDrawPanel(); }
public override void Execute() { int width = (int)CmdLine.GetArg(0).Value; CheckIntRange(width, 1, int.MaxValue, "Width", CmdLine.GetArg(0).CharPos); Open(); try { while (!EndOfText) { string line = ReadLine(); int i = (width - line.Length) / 2; if (i > 0) { WriteText(string.Empty.PadRight(i) + line); } else { WriteText(line); } } } finally { Close(); } }
public override void Execute() { int noOfChars = (int)CmdLine.GetArg(0).Value; CheckIntRange(noOfChars, 1, int.MaxValue, "No. of characters", CmdLine.GetArg(0).CharPos); Open(); try { while (!EndOfText) { string line = ReadLine(); if (line.Length > noOfChars) { line = line.Substring(0, noOfChars); } WriteText(line); } } finally { Close(); } }
public void RunApplication(string[] args) { var cmdLine = new CmdLine(); try { cmdLine.Parse(args); } catch (Exception e) { Platform.Log(LogLevel.Info, e); Console.WriteLine(e.Message); cmdLine.PrintUsage(Console.Out); Environment.Exit(-1); } int timeoutMillisecondsRemaining = cmdLine.Timeout * 1000; int tryCount = 0; while (timeoutMillisecondsRemaining > 0) { ++tryCount; if (tryCount > 1) { Platform.Log(LogLevel.Info, "Previous attempt to start re-index failed - trying again (attempt #{0})", tryCount); Console.WriteLine("Previous attempt to start re-index failed - trying again (attempt #{0})", tryCount); } int startTicks = Environment.TickCount; try { var client = new ReindexFilestoreBridge(); client.Reindex(); Console.WriteLine("The re-index has been scheduled."); Environment.ExitCode = 0; return; } catch (EndpointNotFoundException) { Platform.Log(LogLevel.Warn, "Failed to start re-index because the Work Item service isn't running."); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Failed to start re-index."); Console.WriteLine("Failed to start re-index."); } finally { Thread.Sleep(2000); var elapsedMilliseconds = Environment.TickCount - startTicks; timeoutMillisecondsRemaining -= elapsedMilliseconds; } } Platform.Log(LogLevel.Warn, "Unable to start re-index after {0} attempts", tryCount); Console.WriteLine("Unable to start re-index after {0} attempts", tryCount); Environment.ExitCode = -1; }
public override void Execute() { int NoOfLines = (int)CmdLine.GetArg(0).Value; CheckIntRange(NoOfLines, 1, int.MaxValue, "No. of lines", CmdLine.GetArg(0).CharPos); Open(); try { while (!EndOfText) { string line = ReadLine(); if (TextLineNo >= TextLineCount - NoOfLines + 1) { WriteText(line); } } } finally { Close(); } }
public static int Main(string[] args) { CmdLine cmd = new CmdLine(args); if (cmd.ArgNum < 1) { PrintUsage(); return -1; } PoseSeq psq = new PoseSeq(); psq.Load(cmd.mArgs[0]); TextWriter tw = Console.Out; string outName = cmd.GetStringOpt("out", null); if (outName != null) { tw = Util.MakeTextFile(outName); } psq.WriteInfo(tw); if (outName != null) { tw.Close(); } return 0; }
public void RunApplication(string[] args) { var cmdLine = new CmdLine(); try { cmdLine.Parse(args); } catch (Exception e) { Platform.Log(LogLevel.Info, e); Console.WriteLine(e.Message); cmdLine.PrintUsage(Console.Out); Environment.Exit(-1); } int timeoutMillisecondsRemaining = cmdLine.Timeout*1000; int tryCount = 0; while (timeoutMillisecondsRemaining > 0) { ++tryCount; if (tryCount > 1) { Platform.Log(LogLevel.Info, "Previous attempt to start re-index failed - trying again (attempt #{0})", tryCount); Console.WriteLine("Previous attempt to start re-index failed - trying again (attempt #{0})", tryCount); } int startTicks = Environment.TickCount; try { var client = new ReindexFilestoreBridge(); client.Reindex(); Console.WriteLine("The re-index has been scheduled."); Environment.ExitCode = 0; return; } catch (EndpointNotFoundException) { Platform.Log(LogLevel.Warn, "Failed to start re-index because the Work Item service isn't running."); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Failed to start re-index."); Console.WriteLine("Failed to start re-index."); } finally { Thread.Sleep(2000); var elapsedMilliseconds = Environment.TickCount - startTicks; timeoutMillisecondsRemaining -= elapsedMilliseconds; } } Platform.Log(LogLevel.Warn, "Unable to start re-index after {0} attempts", tryCount); Console.WriteLine("Unable to start re-index after {0} attempts", tryCount); Environment.ExitCode = -1; }