private static bool RunCommands() { ICommand cmd = new HelpCommand(); if (!string.IsNullOrEmpty(ArgSettings.Help)) { cmd = new HelpCommand(); } else if (ArgSettings.List) { cmd = new ListCommand(); } else if (ArgSettings.Remove) { cmd = new RemoveCommand(); } else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) && ArgumentsHelper.IsValidUri(ArgSettings.Destination) && ArgumentsHelper.IsValidAzureConnection(ArgSettings.SourceConnection)) { cmd = new CopyCommand(); } else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) && ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Destination)) { cmd = new DownloadCommand(); } else if (ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Source) && ArgumentsHelper.IsValidUri(ArgSettings.Destination)) { cmd = new UploadCommand(); } return(cmd.Execute()); }
public override void Execute() { if (!ProcessTemplate) { return; } IDictionaryService dictionaryService = GetService <IDictionaryService>(); this.template = ArgumentsHelper.ReplaceToken(this.Template, dictionaryService); this.dynamicTemplate = ArgumentsHelper.ReplaceToken(this.DynamicTemplate, dictionaryService); if (!string.IsNullOrEmpty(dynamicTemplate)) { this.template = dynamicTemplate; } if (template == null) { throw new ArgumentNullException("Template"); } string templateBasePath = base.GetTemplateBasePath(); if (!Path.IsPathRooted(template)) { Template = Path.Combine(templateBasePath, template); } string templateFilename = new FileInfo(template).FullName; if (!templateFilename.StartsWith(templateBasePath)) { throw new ArgumentException(string.Empty); } string templateContent = File.ReadAllText(templateFilename); this.Content = base.Render(templateContent, templateFilename); }
public void TestGetLogFile3() { string[] input = new string[] { "-o", "output.txt" }; // return default on null Assert.Equal("fail2ban.log", ArgumentsHelper.GetInputFile(input)); }
public override void Execute() { if (string.IsNullOrEmpty(RuntimeProviderBaseType)) { RuntimeProviderBaseType = RuntimeProviderRootType; } IDictionaryService dictionaryService = GetService <IDictionaryService>(); providerInfo = new ProviderInfo(); providerInfo.Namespace = Namespace; providerInfo.ExtendedNamespace = ExtendedNamespace; providerInfo.NamespacesConfiguration = NamespacesConfiguration; providerInfo.NamespacesRuntime = NamespacesRuntime; providerInfo.ProviderName = ProviderName; providerInfo.RuntimeConfigurationBaseType = RuntimeConfigurationBaseType; providerInfo.RuntimeProviderBaseType = RuntimeProviderBaseType; providerInfo.RuntimeProviderRootType = RuntimeProviderRootType; providerInfo.ConfigurationElementType = ConfigurationElementType; providerInfo.IncludeConfigurationTypeElement = IncludeConfigurationTypeElement; providerInfo.RuntimeClassName = !string.IsNullOrEmpty(RuntimeClassName) ? RuntimeClassName : GenerateRuntimeClassName(); providerInfo.ConfigurationClassName = !string.IsNullOrEmpty(ConfigurationClassName) ? ConfigurationClassName : GenerateConfigurationClassName(); providerInfo.GenerateRuntimeConstructors = GenerateRuntimeConstructors; DefaultRuntimeImplementationTemplate = ArgumentsHelper.ReplaceToken(DefaultRuntimeImplementationTemplate, dictionaryService); }
static int Main(string[] args) { // get verbose level to determine how much to print in console VerboseLevel verboseLevel = ArgumentsHelper.GetVerboseLevel(args); if (verboseLevel == VerboseLevel.All) { Console.WriteLine("verbose level set to \"{0}\".", verboseLevel); } if (args.Length < 2) { Console.WriteLine(usageText); return(1); } //foreach (string s in args) //{ // Console.WriteLine(s); //} string inputFile = ArgumentsHelper.GetInputFile(args); if (verboseLevel == VerboseLevel.All) { Console.WriteLine("reading log file \"{0}\".", inputFile); } return(0); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IDictionaryService dictionaryService = (IDictionaryService)provider.GetService(typeof(IDictionaryService)); initialDirectory = ArgumentsHelper.ReplaceToken(initialDirectoryExpression, dictionaryService); object svc = provider.GetService(typeof(IWindowsFormsEditorService)); if (svc == null) { return(base.EditValue(context, provider, value)); } OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = Title; fileDialog.InitialDirectory = InitialDirectory; fileDialog.Filter = FileFilter; fileDialog.FilterIndex = 1; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() == DialogResult.OK) { return(fileDialog.FileName); } else { return(string.Empty); } }
private ArgumentsHelper CreateArgumentsHelper() { var helper = new ArgumentsHelper(); helper.BuildArgumentsDictionary(new[] { "-Arg1=Value", "-Arg2=Value1" }); return(helper); }
/// <summary> /// Uses <see cref="DteHelper.FindItemByName"/> to search for the item specified by the "Name" attributte /// </summary> /// <param name="currentValue"></param> /// <param name="newValue"></param> /// <returns></returns> /// <seealso cref="ValueProvider.OnBeginRecipe"/> /// <seealso cref="DteHelper.FindItemByName"/> public override bool OnBeginRecipe(object currentValue, out object newValue) { if (currentValue == null) { IDictionaryService dictservice = (IDictionaryService) ServiceHelper.GetService(this, typeof(IDictionaryService)); string itemFullName = ArgumentsHelper.ReplaceToken(itemFullNameExpression, dictservice); Project project = dictservice.GetValue(projectArgumentName) as Project; if (project != null) { try { newValue = DteHelper.FindItemByName(project.ProjectItems, itemFullName, true); } catch { //With Web projects without any subfolder this method throws an exception newValue = DteHelper.FindItemByName(project.ProjectItems, itemFullName, false); } if (newValue != null) { return(true); } } } newValue = currentValue; return(false); }
public static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { string[] args = Environment.GetCommandLineArgs(); ArgumentsHelper cmdline = new ArgumentsHelper(args); if (Convert.ToBoolean(cmdline["register"])) { ShellMenuHelper.Register(cmdline["exe"], cmdline["cd"]); MessageBox.Show("Register ShellMenu sucessfully"); } if (Convert.ToBoolean(cmdline["unregister"])) { ShellMenuHelper.UnRegister(); MessageBox.Show("UnRegister ShellMenu sucessfully"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool Execute() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Downloading blobs (press ESC to cancel)..."); Console.ResetColor(); Console.WriteLine(); var blobs = (new ListBlobsHelper(this.listing)).ListBlobsFromArgs(); var cts = new CancellationTokenSource(); var completed = false; if (string.IsNullOrEmpty(ArgSettings.SourceConnection)) { ArgSettings.SourceConnection = "UseDevelopmentStorage=true"; } var task = Task.Factory.StartNew(() => { downloader.DownloadFiles(string.Empty, blobs, ArgSettings.Destination, ArgSettings.SourceConnection, cts.Token, (f) => { Console.WriteLine(f); }, (f, e) => { Console.Error.WriteLine("Failed to download {0}: {1}", f, e.ToString()); }, () => { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.WriteLine("Finished downloading files."); Console.ResetColor(); completed = true; }); }, cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); while (!completed) { if (ArgumentsHelper.IsKeyAvailable()) { if (Console.ReadKey(true).Key == ConsoleKey.Escape) { cts.Cancel(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Cancelled!"); Console.ResetColor(); return(false); } } } return(true); }
public void CreateStatsStrategy_ValidName_Instance() { var actual = ArgumentsHelper.CreateStatsStrategy("Memory"); Assert.IsInstanceOf <MemoryStatsStrategy>(actual); actual = ArgumentsHelper.CreateStatsStrategy("PerformanceCounter"); Assert.IsInstanceOf <MemoryStatsStrategy>(actual); }
public void CreateEventLog_ValidName_Instance() { var actual = ArgumentsHelper.CreateEventLog("Console"); Assert.IsInstanceOf <MemoryStatsStrategy>(actual); actual = ArgumentsHelper.CreateEventLog("Windows"); Assert.IsInstanceOf <MemoryStatsStrategy>(actual); }
private static async Task <int> Start() { ICommand cmd = null; var args = ArgumentsHelper.SplitArgs(ArgumentsHelper.GetRealCommandLine()); try { cmd = ArgumentsHelper.ParseCommand(args); if (cmd != null) { try { return(await cmd.Execute().ConfigureAwait(false)); } finally { (cmd as IDisposable)?.Dispose(); } } return(0); } catch (ApplicationException ex) { Logger.Instance.Log(ex.Message, LogLevel.Error); // one liner errors. return(Constants.GSUDO_ERROR_EXITCODE); } catch (Exception ex) { Logger.Instance.Log(ex.ToString(), LogLevel.Error); // verbose errors. return(Constants.GSUDO_ERROR_EXITCODE); } finally { if (InputArguments.KillCache) { await new KillCacheCommand(verbose: false).Execute().ConfigureAwait(false); } try { // cleanup console before returning. Console.CursorVisible = true; Console.ResetColor(); if (InputArguments.Debug && !Console.IsInputRedirected && cmd.GetType().In(typeof(ServiceCommand), typeof(ElevateCommand))) { Console.WriteLine("Press any key to exit."); Console.ReadKey(); } } catch { } } }
public void CanParseLine_Test() { var args = ArgumentsHelper.Split("git commit -m 'message 123' "); args.ShouldContain("git"); args.ShouldContain("commit"); args.ShouldContain("-m"); args.ShouldContain("message 123"); args.ShouldNotContain(" "); args.ShouldNotContain(string.Empty); }
public static async Task UpdateTilesAsync(AccountDataItem account, AccountDataStore data, IEnumerable <SecondaryTile> tilesForAccount) { foreach (var tile in tilesForAccount) { var args = ArgumentsHelper.Parse(tile.Arguments) as ViewClassArguments; if (args != null) { await UpdateTileAsync(tile, account, data, args.ItemId); } } }
private bool ExtendsTheCallerType(IMethodElement method, ITypeElement callerType, Expression qualifier) { if (method == null || callerType == null) { return(false); } if (method.Parameters.Count == 0) { return(false); } ISourceTreeResolver resolver = ParserServices.SourceTreeResolver; ExpressionCollection arguments = new ExpressionCollection(); arguments.Add(qualifier); method = GenericElementActivator.ActivateMemberIfNeeded(resolver, method, arguments, null, ArgumentsHelper.ResolveArgumentTypes(resolver, arguments)) as IMethodElement; if (method == null) { return(false); } IParameterElement extensionParam = method.Parameters[0] as IParameterElement; if (extensionParam == null) { return(false); } ITypeReferenceExpression typeRef = extensionParam.Type; if (typeRef == null) { return(false); } ITypeElement type = typeRef.GetDeclaration() as ITypeElement; if (type == null) { return(false); } IArrayTypeElement arrayType = callerType as IArrayTypeElement; //if (arrayType != null) //{ // return true; //} //else return(ArgumentsHelper.HasParamConversion(resolver, extensionParam, callerType, qualifier, TypeConversionMode.ImplicitConversion)); }
public Task <int> Execute() { var caller = Process.GetCurrentProcess().GetParentProcessExcludingShim().MainModule.ModuleName; var length = (int)NativeMethods.GetConsoleCommandHistoryLength(caller); if (length == 0) { throw new ApplicationException("Failed to find last invoked command (GetConsoleCommandHistoryLength==0)"); } IntPtr CommandBuffer = Marshal.AllocHGlobal(length); var ret = NativeMethods.GetConsoleCommandHistory(CommandBuffer, length, caller); if (ret == 0) { throw new ApplicationException($"Failed to find last invoked command (GetConsoleCommandHistory=0; LastErr={Marshal.GetLastWin32Error()})"); } string commandToElevate; var commandHistory = Marshal.PtrToStringAuto(CommandBuffer, length / 2) .Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries) .Reverse() // look for last commands first .Skip(1) // skip gsudo call ; if (Pattern == "!!") { commandToElevate = commandHistory.FirstOrDefault(); } else if (Pattern.StartsWith("!?", StringComparison.OrdinalIgnoreCase)) { commandToElevate = commandHistory.FirstOrDefault(s => s.Contains(Pattern.Substring(2).Trim())); } else // Pattern.StartsWith ("!command") { commandToElevate = commandHistory.FirstOrDefault(s => s.StartsWith(Pattern.Substring(1).Trim(), StringComparison.OrdinalIgnoreCase)); } if (commandToElevate == null) { throw new ApplicationException("Failed to find last invoked command in history."); } Logger.Instance.Log("Command to run: " + commandToElevate, LogLevel.Info); return(new RunCommand() { CommandToRun = ArgumentsHelper.SplitArgs(commandToElevate) } .Execute()); }
public void Arguments_NoQuotesTests() { var input = "HEllo I Am my params OtherParam1 OtherParam2 OtherParam3"; var expected = new string[] { "HEllo", "I", "Am", "my", "params", "OtherParam1", "OtherParam2", "OtherParam3" }; var actual = ArgumentsHelper.SplitArgs(input).ToArray(); Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i]); } }
public void Arguments_QuotedTests() { var input = "\"my exe name\" \"my params\" OtherParam1 OtherParam2 OtherParam3"; var expected = new string[] { "\"my exe name\"", "\"my params\"", "OtherParam1", "OtherParam2", "OtherParam3" }; var actual = ArgumentsHelper.SplitArgs(input).ToArray(); Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i]); } }
private static async Task <int> Start() { ICommand cmd = null; var args = ArgumentsHelper.SplitArgs(ArgumentsHelper.GetRealCommandLine()); var parserError = ArgumentsHelper.ParseCommonSettings(ref args); if (parserError.HasValue) { return(parserError.Value); } cmd = ArgumentsHelper.ParseCommand(args); try { if (cmd != null) { try { return(await cmd.Execute().ConfigureAwait(false)); } finally { (cmd as IDisposable)?.Dispose(); } } else { return(await new HelpCommand().Execute().ConfigureAwait(false)); } } catch (Exception ex) { Logger.Instance.Log(ex.ToString(), LogLevel.Error); return(Constants.GSUDO_ERROR_EXITCODE); } finally { try { // cleanup console before returning. Console.CursorVisible = true; Console.ResetColor(); } catch { } } }
public void ArgumentsHelperPopulatesDictionaryWithParameters() { var arguments = new[] { "-Arg1=Value", "-Arg2=AnotherValue" }; var helper = new ArgumentsHelper(null); helper.BuildArgumentsDictionary(arguments); Assert.Equal(2, helper.Keys.Count); Assert.True(helper.ContainsKey("-Arg1")); Assert.Equal("Value", helper.Get("-Arg1")); }
public override bool OnBeginRecipe(object currentValue, out object newValue) { IDictionaryService dictionaryService = (IDictionaryService)GetService <IDictionaryService>(); string typeFullName = ArgumentsHelper.ReplaceToken(typeFullNameExpression, dictionaryService); DTE vs = GetService <DTE>(); Type type = TypeHelper.GetType(vs, typeFullName, useProjectItemWrapper); if (type != null) { newValue = type; return(true); } newValue = null; return(false); }
public void SetArgs_ShouldUnderstandOpenArg(string arg) { ArgumentsHelper.SetArgs(arg); Assert.AreEqual(true, ArgumentsHelper.HasConnectionSpecified); Assert.AreEqual(2, ArgumentsHelper.SpecifiedConnections.Count()); // SpecifiedConnections var conn1 = ArgumentsHelper.SpecifiedConnections.ElementAt(0); Assert.AreEqual(ConnectionType.RDP, conn1.Type); Assert.AreEqual(13, conn1.ConnectionId); var conn2 = ArgumentsHelper.SpecifiedConnections.ElementAt(1); Assert.AreEqual(ConnectionType.SSH, conn2.Type); Assert.AreEqual(2, conn2.ConnectionId); }
public TokenSwitchRenderer(Connection connection, ElevationRequest elevationRequest) { if (Settings.SecurityEnforceUacIsolation && !elevationRequest.NewWindow) { throw new Exception("TokenSwitch mode not supported when SecurityEnforceUacIsolation is set."); } _connection = connection; _elevationRequest = elevationRequest; Environment.SetEnvironmentVariable("prompt", Environment.ExpandEnvironmentVariables(elevationRequest.Prompt)); ProcessApi.CreateProcessFlags dwCreationFlags = ProcessApi.CreateProcessFlags.CREATE_SUSPENDED; if (elevationRequest.NewWindow) { dwCreationFlags |= ProcessApi.CreateProcessFlags.CREATE_NEW_CONSOLE; } string exeName, args; if (elevationRequest.IntegrityLevel == IntegrityLevel.MediumPlus && ArgumentsHelper.UnQuote(elevationRequest.FileName.ToUpperInvariant()) != Environment.GetEnvironmentVariable("COMSPEC").ToUpperInvariant()) { // Now, we have an issue with this method: The process launched with the new token throws Access Denied if it tries to read its own token. // Kind of dirty workaround is to wrap the call with a "CMD.exe /c ".. this intermediate process will then // launching the command with a fresh new (desired) token and we know cmd wont try to read it's substitute token (throwing Access Denied). exeName = Environment.GetEnvironmentVariable("COMSPEC"); args = $"/s /c \"{elevationRequest.FileName} {elevationRequest.Arguments}\""; } else { // Hack not needed if we are already calling CMD exeName = elevationRequest.FileName; args = elevationRequest.Arguments; } _process = ProcessFactory.CreateProcessAsUserWithFlags(exeName, args, dwCreationFlags, out _processInformation); elevationRequest.TargetProcessId = _processInformation.dwProcessId; if (!elevationRequest.NewWindow) { ConsoleApi.SetConsoleCtrlHandler(ConsoleHelper.IgnoreConsoleCancelKeyPress, true); } }
public override void Execute() { DTE vs = GetService <DTE>(); string resourcesFileName = Resources.get_FileNames(1); SourceControlHelper.EnsureWritable(vs, resourcesFileName); IDictionaryService dictionaryService = GetService <IDictionaryService>(); ResourcesHelper.AddResource(resourcesFileName, ArgumentsHelper.ReplaceToken(ResourceName, dictionaryService), ArgumentsHelper.ReplaceToken(ResourceValue, dictionaryService)); VSProjectItem vsResources = Resources.Object as VSProjectItem; if (vsResources != null && RunCustomTool) { vsResources.RunCustomTool(); } }
public override void Execute() { IDictionaryService dictionaryService = (IDictionaryService)GetService <IDictionaryService>(); DesignTimeNodeInfo = new DesignTimeNodeInfo(); DesignTimeNodeInfo.DesignTimeProperties = DesignTimeProperties; DesignTimeNodeInfo.ConfigurationType = RuntimeConfigurationType; DesignTimeNodeInfo.ConfigurationBaseType = RuntimeConfigurationType != null ? RuntimeConfigurationType.BaseType : null; DesignTimeNodeInfo.BaseNodeName = ArgumentsHelper.ReplaceToken(BaseNodeName, dictionaryService); DesignTimeNodeInfo.ParentUINodeName = ParentUINodeName; DesignTimeNodeInfo.NodeName = ArgumentsHelper.ReplaceToken(NodeName, dictionaryService); DesignTimeNodeInfo.Namespace = Namespace; DesignTimeNodeInfo.ExtendedNamespace = ExtendedNamespace; DesignTimeNodeInfo.Cardinality = this.Cardinality; DesignTimeNodeInfo.AbstractNode = AbstractNode; DesignTimeNodeInfo.PolymorphicProvider = IsPolymorphic(); DesignTimeNodeInfo.ProviderName = ProviderName; }
public static int Main(string[] args) { // cloudcopy.exe "source" "destination" "blobcnstring (default dev storage)" -flags // cloudcopy.exe "C:\Test\*.*" "mycontainer/myfolder" "DefaultEndpointsProtocal=http;AccountName=userdevelopment;AccountKey=accKey" // cloudcopy.exe "C:\Test\*.*" "/mycontainer/myfolder" "DefaultEndpointsProtocal=http;AccountName=userdevelopment;AccountKey=accKey" // cloudcopy.exe "/mycontainer/myfolder" "C:\Test\*.*" "DefaultEndpointsProtocal=http;AccountName=userdevelopment;AccountKey=accKey" // cloudcopy.exe "/mycontainer/myfolder" "/mycontainer/myfolder" "DefaultEndpointsProtocal=http;AccountName=userdevelopmentA;AccountKey=accKeyA" "DefaultEndpointsProtocal=http;AccountName=userdevelopmentB;AccountKey=accKeyB" // cloudcopy.exe "C:\Test\*.*" "/mycontainer/myfolder" // cloudcopy.exe "/mycontainer/myfolder" "DefaultEndpointsProtocal=http;AccountName=userdevelopment;AccountKey=accKey" -L if (ArgumentsHelper.Parse(args)) { return(RunCommands() ? 0 : 1); } else { return(1); } }
protected override void OnStartup(StartupEventArgs e) { ArgumentsHelper.SetArgs(e.Args); base.OnStartup(e); // Local method to enqueue connections specified with command-line argument bool EnqueueOpenRequestedConnections(IProcessCommander processCommander) { if (!ArgumentsHelper.HasConnectionSpecified) { return(false); } foreach (var conn in ArgumentsHelper.SpecifiedConnections) { MyLogger.Log($"Connection (Type: {conn.Type}, Id: {conn.ConnectionId}) has been enqueued."); processCommander.Invoke(conn.Type, conn.ConnectionId); } return(true); } if (SingleAppInstanceHelper.TryStart()) { // Boot as an IPC host var service = new ProcessCommander { ConnectionRequest = ConnectionRequest.Singleton, }; var serviceHost = IPCService.OpenServiceHost(service); EnqueueOpenRequestedConnections(service); } else { // Boot as an IPC client var channel = IPCService.CreateServiceChannel(); if (!EnqueueOpenRequestedConnections(channel)) { MyLogger.Log("Shutting down because another application instance has already run..."); } channel.Activate(); // Shutdown after activate the primary window Shutdown(); } }
public Task <int> Execute() { RegistrySetting setting = null; if (key == null) { foreach (var k in GlobalSettings.AllKeys) { Console.WriteLine($"{k.Value.Name} = \"{ k.Value.GetStringValue().ToString()}\""); } return(Task.FromResult(0)); } GlobalSettings.AllKeys.TryGetValue(key, out setting); if (setting == null) { Console.WriteLine($"Invalid Setting '{key}'.", LogLevel.Error); return(Task.FromResult(Constants.GSUDO_ERROR_EXITCODE)); } if (value != null && value.Any()) { if (value.FirstOrDefault().In("--reset")) { setting.Reset(); // reset to default value } else if (value.Count() == 1) { setting.Save(ArgumentsHelper.UnQuote(value.FirstOrDefault()).Replace("\\%", "%")); } else { setting.Save(string.Join(" ", value.ToArray())); } } // READ Console.WriteLine($"{setting.Name} = \"{ setting.GetStringValue().ToString()}\""); return(Task.FromResult(0)); }
public static void LoadTextBoxFolder(TextBox textBoxFolder, SettingsConfiguration settings) { string[] args = Environment.GetCommandLineArgs(); ArgumentsHelper cmdline = new ArgumentsHelper(args); string cd = cmdline["cd"]; if (!string.IsNullOrWhiteSpace(cd)) { textBoxFolder.Text = cd; } else { string folderDefault = settings.FolderDefault; if (!string.IsNullOrWhiteSpace(folderDefault)) { textBoxFolder.Text = folderDefault; } } }
public static string Execute(string args, IDebugClient debugClient) { if(CSDebugger==null) { IDebugClient client; debugClient.CreateClient(out client); mngdDebugClient = client; var windbgDebugger = new Debugger(client); CSDebugger = windbgDebugger; } //testig the execute function //string interoutput = windbgDebugger.Execute("k"); //windbgDebugger.OutputLine(interoutput); bool persistSession = true; //windbgDebugger.OutputLine("starting {0} ", "Execute"); Output = string.Empty; try { ArgumentsHelper arguments = new ArgumentsHelper(args); if (!arguments.HasArgument("-help")) { ScriptContext context = new ScriptContext(); Debugger.Current.Context = context; context.Debug = IsDebugMode; if (arguments.HasArgument("-file")) { isScript = false; ParsedPath = arguments["-file"]; context.Args = arguments; context.ScriptLocation = Path.GetDirectoryName(ParsedPath); persistSession = true; } else if (arguments.HasArgument("-debug")) { if (IsDebugMode) { IsDebugMode = false; Debugger.Current.Output("Script debug mode is off\n"); } else { IsDebugMode = true; Debugger.Current.Output("Script debug mode is on\n"); } return ""; } else if (arguments.HasArgument("-clear")) { Session = null; DebuggerScriptEngine.Clear(); Debugger.Current.Output("Script session cleared\n"); Output = string.Empty; return "Session cleared"; } else { isScript = true; CSScript = args; } var session = CreateSession(CSDebugger, persistSession); //session.Execute("using WindbgManagedExt;"); //Submission<Object> CSession = session.CompileSubmission<Object>(CSScript); //var references = CSession.Compilation.References; //foreach (MetadataReference reference in references) //{ // if (reference.Display.Contains("ExtCS.Debugger")) // CSession.Compilation.RemoveReferences(reference); //} if (isScript) session.Execute(CSScript); else { if (CSDebugger.Context.Debug) DebuggerScriptEngine.Execute(session, ParsedPath); else session.ExecuteFile(ParsedPath); } } else ShowHelp(arguments["-help"]); } catch (Exception ex) { Session = null; CSDebugger.OutputError("\n\nException while executing the script {0}", ex.Message); CSDebugger.OutputDebugInfo("\n Details: {0} \n", ex.ToString()); } //windbgDebugger.OutputLine("ending Execute"); CSDebugger.Output(Output); CSDebugger.Output("\n"); Output = ""; return Output; }