public SearchWindow(Searcher searcher) { _trace = DiagnosticsCenter.GetTraceSource(nameof(SearchWindow)); _searcher = searcher ?? throw new ArgumentNullException(nameof(searcher)); CurrentFindings = new ObservableCollection <IStoredItem>(); DataContext = this; InitializeComponent(); }
public AttachSelector() { _trace = DiagnosticsCenter.GetTraceSource(nameof(AttachSelector)); ProcessItems = new ObservableCollection <ProcessItem>(); DataContext = this; InitializeComponent(); }
public FileStore(FileInfo fileInfo) { if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } _trace = DiagnosticsCenter.GetTraceSource(nameof(FileStore) + "-Other"); _fileInfo = fileInfo; }
public Searcher(IDataStore dataStore) { _trace = DiagnosticsCenter.GetTraceSource(nameof(Searcher)); _dataStore = dataStore; _newRequest = new SemaphoreSlim(0, int.MaxValue); _requests = new ConcurrentQueue <Request>(); _thread = new Thread(BackgroundThread); _thread.IsBackground = true; _thread.Start(); }
public FileStore(Configuration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _trace = DiagnosticsCenter.GetTraceSource(nameof(FileStore) + "-Session"); var dataFileName = Path.Combine(config.LocalDbDirectory.ToString(), $"{config.SessionId}.dat"); _fileInfo = new FileInfo(dataFileName); }
public ReplicationJob(string jobName, DirectoryInfo source, DirectoryInfo destination, TimeSpan timeBetweenPolls, Func <string, bool> accept) { _trace = DiagnosticsCenter.GetTraceSource(jobName); _source = source; _destination = destination; _thread = new Thread(Run); _thread.IsBackground = true; _thread.Priority = ThreadPriority.Lowest; _timeBetweenPolls = timeBetweenPolls; _accept = accept; }
public MainWindow(FamiliarCommandLineArguments args, int parentPid, IntPtr targetWindow) { // Safe initializations. Do not put anything here that can throw an exception. // Defer to loaded. _trace = DiagnosticsCenter.GetTraceSource(nameof(MainWindow)); _args = args; _pid = parentPid; _machineName = Environment.MachineName; var inputLanguage = InputLanguage.CurrentInputLanguage; _trace.TraceVerbose("Input language {0}: {1}", nameof(inputLanguage.LayoutName), inputLanguage.LayoutName); var culture = inputLanguage.Culture; _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.DisplayName), culture.DisplayName); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.EnglishName), culture.EnglishName); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.IsNeutralCulture), culture.IsNeutralCulture); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.Name), culture.Name); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.KeyboardLayoutId), culture.KeyboardLayoutId); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.NativeName), culture.NativeName); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.ThreeLetterISOLanguageName), culture.ThreeLetterISOLanguageName); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.ThreeLetterWindowsLanguageName), culture.ThreeLetterWindowsLanguageName); _trace.TraceVerbose("Input language culture {0}: {1}", nameof(culture.TwoLetterISOLanguageName), culture.TwoLetterISOLanguageName); var textInfo = culture.TextInfo; _trace.TraceVerbose("Input language culture text info {0}: {1}", nameof(textInfo.ANSICodePage), textInfo.ANSICodePage); _trace.TraceVerbose("Input language culture text info {0}: {1}", nameof(textInfo.CultureName), textInfo.CultureName); _trace.TraceVerbose("Input language culture text info {0}: {1}", nameof(textInfo.EBCDICCodePage), textInfo.EBCDICCodePage); _trace.TraceVerbose("Input language culture text info {0}: {1}", nameof(textInfo.MacCodePage), textInfo.MacCodePage); _trace.TraceVerbose("Input language culture text info {0}: {1}", nameof(textInfo.OEMCodePage), textInfo.OEMCodePage); _parentProcess = Process.GetProcessById(parentPid); _parentProcessObserver = new Thread(ParentProcessObserver); _parentProcessObserver.IsBackground = true; _targetWindow = targetWindow; _consoleWindowObserver = new Thread(ConsoleWindowObserver); // Set priority a bit higher than normal so this thread get cycles when our app is not active. //_consoleWindowObserver.Priority = ThreadPriority.AboveNormal; // Commented to avoid issues on 2016 server. _consoleWindowObserver.IsBackground = true; InitializeComponent(); _trace.TraceVerbose("Main window object created."); }
public InboundReplication(DirectoryInfo source, DirectoryInfo destination, TimeSpan timeBetweenPolls, Func <string, bool> accept) { _trace = DiagnosticsCenter.GetTraceSource(nameof(InboundReplication)); _source = source; _destination = destination; _random = new Random(); _state = new ReplicationState(_trace, _destination); var escapedName = _destination.FullName.Replace(":\\", "\\").Replace('\\', '/'); _mutexName = $"familiar/replication/{escapedName}"; _mutex = new Mutex(false, _mutexName); _thread = new Thread(Run); _thread.IsBackground = true; _thread.Priority = ThreadPriority.Lowest; _timeBetweenPolls = timeBetweenPolls; _accept = accept; }
private void OnStartup(object sender, StartupEventArgs e) { LogViewTraceListener.Actual = new WindowsApplicationEventTraceListener(); _trace = DiagnosticsCenter.GetTraceSource(nameof(App)); var currentProcess = Process.GetCurrentProcess(); var currentPid = currentProcess.Id; var message = new StringBuilder(); message.AppendLine("Starting the familiar."); message.AppendLine($"PID: {currentPid}"); message.AppendLine($"Image: {currentProcess.MainModule.FileName}"); var args = Environment.GetCommandLineArgs(); for (var i = 0; i < args.Length; ++i) { message.AppendLine($"args[{i}]: {args[i]}"); } _trace.TraceInformation("{0}", message); try { var resolvedArgs = ParseCommandLine(args); if (resolvedArgs == null) { return; } if (resolvedArgs.TestFile != null) { ConsoleNeeded(true); PerformFileTest(resolvedArgs.TestFile); Current.Shutdown(ExitCodes.Success); return; } if (resolvedArgs.ShowInfo) { ConsoleNeeded(); ShowInformation(resolvedArgs); Current.Shutdown(ExitCodes.Success); return; } if (resolvedArgs.Connect != null) { ConsoleNeeded(true); ConnectToSharedDir(resolvedArgs); Current.Shutdown(ExitCodes.Success); return; } if (!SelectWindow(resolvedArgs, currentProcess, out var parentPid, out var targetWindow)) { return; } var mutexName = $"fam-{parentPid}"; _trace.TraceVerbose("Creating mutex named {0}...", mutexName); _mutex = new Mutex(false, mutexName, out var createdNew); if (!createdNew) { _mutex.Dispose(); _mutex = null; _trace.TraceWarning("Unable to create mutex {0}. This process ({1}) will attempt to find a previous one attached to PID {2} and activate.", mutexName, currentPid, parentPid); BringCurrentToFront(parentPid, currentPid); Current.Shutdown(ExitCodes.PreviousInstanceDetected); return; } Current.ShutdownMode = ShutdownMode.OnMainWindowClose; var mainWindow = new MainWindow(resolvedArgs, parentPid, targetWindow); //Current.MainWindow = mainWindow; _trace.TraceInformation("Showing main window."); mainWindow.Show(); } catch (Exception exception) { ConsoleNeeded(true); _trace.TraceError("{0}", exception); } }