public SDBCapability(SDBDeviceInfo device) { string[] args = { "-s", device.Serial, SDBProtocol.capability }; string returnValue; using (ProcessProxy p = new ProcessProxy()) { p.StartInfo.FileName = SDBLib.GetSdbFilePath(); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.Arguments = string.Join(" ", args); Debug.WriteLine("{0} SDBCapability command '{1}'", DateTime.Now, p.StartInfo.Arguments); p.Start(); returnValue = p.StandardOutput.ReadToEnd().Replace("\r", string.Empty); p.WaitForExit(); } IsSupported = !string.IsNullOrEmpty(returnValue); if (IsSupported) { GenCapDic(returnValue); } }
private static WorkStatus WorkUntilCanAttach(object arg, WorkItem workItem) { WorkStatus result = WorkStatus.NotDone; ProcessProxy processProxy = (ProcessProxy)arg; Process remoteProcess = processProxy.RemoteProcess; try { if (remoteProcess != null) { remoteProcess.Refresh(); if (!remoteProcess.HasExited) { if (!MediaControl.CanAttach(new SelectProcessArgs(processProxy.RemoteProcess, processProxy.CLRVersion))) { Thread.Sleep(500); return(result); } return(WorkStatus.Done); } return(WorkStatus.Error); } return(WorkStatus.Error); } catch (Exception) { return(WorkStatus.Error); } }
public void MainWindowHandleGetter_GivenProcess_ReturnsMainWindowHandle() { var process = GetTrayProcess(); var sut = new ProcessProxy(process); sut.MainWindowHandle.Should().Be(process.MainWindowHandle); }
protected bool StartRemoteApplication(string sdkCode) { string appId = _sessionConfiguration.AppId; DebugWriteToOutput($"Starting launch_app({appId}; SDK={sdkCode})"); ProcessProxy launchAppProcess = SDBLib.CreateSdbProcess(true, true); if (launchAppProcess == null) { WriteToOutput(SDBLib.FormatSdbRunResult(SDBLib.SdbRunResult.CreateProcessError)); return(false); } launchAppProcess.StartInfo.Arguments = GetSdbLaunchCommand(sdkCode); string firstOutputLine = null; _launchAppStartedEvent.Reset(); launchAppProcess.OutputDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { firstOutputLine = e.Data; _launchAppStartedEvent.Set(); DebugWriteToOutput($"{appId} : {e.Data}"); } }); launchAppProcess.ErrorDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { DebugWriteToOutput($"{appId} [StdErr] {e.Data}"); } }); launchAppProcess.Exited += (object sender, EventArgs e) => { DebugWriteToOutput($"launch_app({appId}) finished"); launchAppProcess.Dispose(); }; Debug.WriteLine("{0} {1} StartRemoteApplication command '{2}'", DateTime.Now, this.ToString(), launchAppProcess.StartInfo.Arguments); launchAppProcess.Start(); DebugWriteProcessToOutput(launchAppProcess); try { launchAppProcess.BeginOutputReadLine(); launchAppProcess.BeginErrorReadLine(); if (_launchAppStartedEvent.WaitOne(30000)) { if (firstOutputLine.EndsWith("launch failed")) { WriteToOutput($"launch_app({appId}) failed"); return(false); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(true); }
private void StartCMD() { returnMsgs = new Queue <string>(); Debug.Log("启动cmd"); proxy = new ProcessProxy(); proxy.Start(); }
public void InspectContext(ProcessProxy context) { ClauseListView.Items.Clear(); List <string> clauses = context.GetClauses(); foreach (string clause in clauses) { ClauseListView.Items.Add(clause); } }
private void OnContextCreated(ProcessProxy context) { if (context.Parent == null) { Dictionary[context.Guid] = CreateNode(null, context); return; } //else TreeCanvasNode parentNode = Dictionary[context.Parent.Guid]; Dictionary[context.Guid] = CreateNode(parentNode, context); }
public ThumbnailGenerationEgg() { collectionFactory = new CollectionFactory(); var streamFactory = new StreamFactory(); var processProxy = new ProcessProxy(); threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory()); pofContext = new PofContext().With(x => { x.MergeContext(new ManagementPofContext()); x.MergeContext(new ThumbnailGeneratorApiPofContext()); }); pofSerializer = new PofSerializer(pofContext); networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(new DnsProxy()), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(new DnsProxy())); thumbnailGeneratorService = new ThumbnailGeneratorServiceImpl(); }
private void Init() { var args = Environment.GetCommandLineArgs(); if (args.Length < 2) { MessageBox.Show("Please provide path to a wpf application"); return; } ProcessStartInfo processStartInfo = new ProcessStartInfo(args[1], string.Empty); processStartInfo.ErrorDialog = true; processStartInfo.WorkingDirectory = string.Empty; try { string directoryName = Path.GetDirectoryName(processStartInfo.FileName); if (Path.IsPathRooted(directoryName) && Directory.Exists(directoryName)) { processStartInfo.WorkingDirectory = directoryName; } ProcessProxy proxy = (ProcessProxy)Activator.CreateInstance(typeof(ProcessProxy), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { processStartInfo, false, clrVersion }, null); SyncWorkItem syncWorkItem = new SyncWorkItem(ProcessHelper.WorkUntilWpfLoaded, proxy, null); SyncWorkItem syncWorkItem3 = syncWorkItem.Next = new SyncWorkItem(WorkUntilCanAttach, proxy, null); if (ProcessHelper.StartProxy(proxy, syncWorkItem) && AttachToProcess(new SelectProcessArgs(proxy.RemoteProcess, clrVersion))) { } IsAttached = mediaControl != null; } catch (ArgumentException) { IsAttached = false; } finally { if (IsAttached) { updateTimer.Start(); } else { updateTimer.Stop(); } } }
private async void OnProcessStateChangedAsync(object sender, ProcessStateChangedEventArgs e) { if (_appServiceBridgeManager.BackgroundProcessLaunched) { string responseValue = await _appServiceBridgeManager.SendRequestToBackgroundProcessAsync( Keys.KeyProcessDetailsByWindowHandleRequest, e.ProcessProxy.MainWindowHandle.ToString()); ProcessProxy processProxy = ProcessProxy.FromJson(responseValue); if (processProxy != null) { System.Diagnostics.Debug.WriteLine("OnProcessStateChangedAsync: " + e + " " + processProxy); logControl.AddLogMessage("Process state changed: " + e.ToString() + " " + processProxy.ToString()); } } else { System.Diagnostics.Debug.WriteLine("OnProcessStateChangedAsync: " + e); logControl.AddLogMessage("Process state changed: " + e.ToString()); } }
public TreeCanvasNode CreateNode(TreeCanvasNode parent, ProcessProxy context) { if (context == null) { return(null); } //else System.Windows.Controls.Button control = new System.Windows.Controls.Button(); control.Content = context.Label; control.Click += (s, e) => InspectContext(context); // TreeCanvasNode canvasNode; if (parent == null) { canvasNode = Canvas.AddRoot(control); } else { canvasNode = Canvas.AddNode(control, parent); } return(canvasNode); }
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { outputWindow.Text = ""; ExternalTool et = GetSelectedExternalTool(); if (et == null) return; ProcessProxy proxy = new ProcessProxy(et.GetCommand(), et.GetParameter(), et.GetWorkingDirectoty()); proxy.OutputDataReceived += new DataReceivedEventHandler(proxy_OutputDataReceived); proxy.StartProcess(); }
public static void Main(string[] args) { InitializeLogging(); // construct libwarty dependencies ICollectionFactory collectionFactory = new CollectionFactory(); // construct libwarty-proxies dependencies IStreamFactory streamFactory = new StreamFactory(); IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory); IThreadingFactory threadingFactory = new ThreadingFactory(); ISynchronizationFactory synchronizationFactory = new SynchronizationFactory(); IThreadingProxy threadingProxy = new ThreadingProxy(threadingFactory, synchronizationFactory); IDnsProxy dnsProxy = new DnsProxy(); ITcpEndPointFactory tcpEndPointFactory = new TcpEndPointFactory(dnsProxy); INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory); ISocketFactory socketFactory = new SocketFactory(tcpEndPointFactory, networkingInternalFactory); INetworkingProxy networkingProxy = new NetworkingProxy(socketFactory, tcpEndPointFactory); IProcessProxy processProxy = new ProcessProxy(); // construct Castle.Core dependencies ProxyGenerator proxyGenerator = new ProxyGenerator(); // construct Platform Root Portable Object Format dependencies IPofContext pofContext = new PlatformPofContext(); IPofSerializer pofSerializer = new PofSerializer(pofContext); // construct libdargon.management dependencies var managementServerEndpoint = tcpEndPointFactory.CreateAnyEndPoint(kPlatformManagementPort); IMessageFactory managementMessageFactory = new MessageFactory(); IManagementSessionFactory managementSessionFactory = new ManagementSessionFactory(collectionFactory, threadingProxy, pofSerializer, managementMessageFactory); ILocalManagementServerContext managementServerContext = new LocalManagementServerContext(collectionFactory, managementSessionFactory); IManagementContextFactory managementContextFactory = new ManagementContextFactory(pofContext); ILocalManagementRegistry localManagementServerRegistry = new LocalManagementRegistry(pofSerializer, managementContextFactory, managementServerContext); IManagementServerConfiguration managementServerConfiguration = new ManagementServerConfiguration(managementServerEndpoint); var server = new LocalManagementServer(threadingProxy, networkingProxy, managementSessionFactory, managementServerContext, managementServerConfiguration); server.Initialize(); // construct system-state dependencies ICache <string, string> systemStateCache = new InMemoryCache <string, string>("SystemState", new ICacheIndex[0]); var platformSystemState = new PlatformSystemStateImpl(systemStateCache); localManagementServerRegistry.RegisterInstance(new PlatformSystemStateMob(platformSystemState)); // construct platform foundational dependencies ICacheFactory cacheFactory = new CacheFactory(); PlatformCacheService platformCacheService = new PlatformCacheServiceImpl(collectionFactory, cacheFactory).With(x => x.Initialize()); Caches specializedCaches = new Caches(platformCacheService); SpecializedCacheService specializedCacheService = new SpecializedCacheServiceImpl(specializedCaches); // construct backend account service dependencies ICache <string, long> emailToAccountIdCache = new InMemoryCache <string, long>(Accounts.Hydar.CacheNames.kEmailToAccountIdCache, new ICacheIndex[0]); ICache <long, AccountInformation> accountInfoByIdCache = new InMemoryCache <long, AccountInformation>(Accounts.Hydar.CacheNames.kAccountInfoByIdCache, new ICacheIndex[0]); IDistributedCounter accountIdCounter = specializedCacheService.GetCountingCache(Accounts.Hydar.CacheNames.kAccountIdCountingCacheName); IPasswordUtilities passwordUtilities = new PasswordUtilities(); AccountCache accountCache = new AccountCache(emailToAccountIdCache, accountInfoByIdCache, accountIdCounter, passwordUtilities); var accountService = new AccountServiceImpl(accountCache); localManagementServerRegistry.RegisterInstance(new AccountCacheMob(accountCache)); // construct frontend identity service dependencies ICache <string, Identity> identityByTokenHydarCache = new InMemoryCache <string, Identity>(Draek.Identities.Hydar.CacheNames.kIdentityByTokenCache, new ICacheIndex[0]); AuthenticationTokenFactory authenticationTokenFactory = new AuthenticationTokenFactoryImpl(); IdentityByTokenCache identityByTokenCache = new IdentityByTokenCacheImpl(identityByTokenHydarCache); IAuthenticationServiceConfiguration authenticationServiceConfiguration = new AuthenticationServiceConfiguration(platformSystemState); AuthenticationService authenticationService = new AuthenticationServiceImpl(accountService, authenticationTokenFactory, identityByTokenCache, authenticationServiceConfiguration); var identityService = new IdentityServiceProxyImpl(authenticationService); localManagementServerRegistry.RegisterInstance(new AuthenticationServiceMob(authenticationService)); localManagementServerRegistry.RegisterInstance(new IdentityCacheMob(identityByTokenCache)); localManagementServerRegistry.RegisterInstance(new AuthenticationServiceConfigurationMob(authenticationServiceConfiguration)); Application.Run(); }