public DraftGetTests() { _proxy = SettingsManager.GetGmailProxy(); _service = new DraftService(_proxy); _helper = CleanupHelpers.GetDraftServiceCleanupHelper(_service); }
public void WriteLine(string value, IDictionary <string, string> attributes, int depth, bool end = false) { string type; attributes.TryGetValue("type", out type); if (type == "request" && end) { // add for delay cleanup CleanupHelper.AddFile(_logFile); } if (!_tracer.ShouldTrace(attributes)) { return; } if (FilterTrace(attributes, out attributes)) { return; } var strb = new System.Text.StringBuilder(); strb.Append(DateTime.UtcNow.ToString("s")); strb.Append(GetIndentation(depth + 1)); if (end) { strb.Append("Done "); } if (type == "process") { strb.Append(attributes["path"]); if (!end) { strb.Append(GetIndentation(1)); strb.Append(attributes["arguments"]); } } else { strb.Append(value); if (!end) { foreach (KeyValuePair <string, string> pair in attributes) { if (TraceExtensions.IsNonDisplayableAttribute(pair.Key)) { continue; } strb.AppendFormat(", {0}: {1}", pair.Key, pair.Value); } } if (type == "request") { if (!end) { _stopWatch = Stopwatch.StartNew(); } else { _stopWatch.Stop(); strb.AppendFormat(", elapsed: {0} ms", _stopWatch.ElapsedMilliseconds); strb.AppendLine(); } } } using (StreamWriter writer = new StreamWriter(_fileSystem.File.Open(_logFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))) { writer.WriteLine(strb.ToString()); } }
public CrossAppDomainCleanUp(AppDomain toWatch, IPrinter printer) { if (toWatch == null) throw new ArgumentNullException("toWatch"); if (printer == null) throw new ArgumentNullException("printer"); (new PermissionSet(PermissionState.Unrestricted)).Assert(); var current = toWatch; AppDomainSetup adSetup = new AppDomainSetup(); adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //#if RAZOR4 // currently not signed! var strongNames = new StrongName[0]; //#else // var strongNames = new[] { // FromAssembly(typeof(RazorEngine.Templating.RazorEngineService).Assembly), // FromAssembly(typeof(System.Web.Razor.RazorTemplateEngine).Assembly) // }; //#endif _domain = AppDomain.CreateDomain( "CleanupHelperDomain_" + Guid.NewGuid().ToString(), null, current.SetupInformation, new PermissionSet(PermissionState.Unrestricted), strongNames); var initHelper = new InitHelper() { Domain = _domain, Current = current }; _helper = ExecutionContextLessThread.DefaultCallFunc(new Func<CleanupHelper>(initHelper.CreateHelper)); }
/// <summary> /// Subscribe to the DomainUnload event and call the helper back. /// </summary> /// <param name="helper"></param> public void Subscribe(CleanupHelper helper) { if (helper == null) { throw new ArgumentNullException("helper"); } _helper = helper; SubscribePrivate(); }
protected override void OnStop() { CleanupLog.WriteMethod(); CleanupHelper.StopCleanup(); }
protected override void OnStart(string[] args) { CleanupLog.WriteMethod(); Task.Run(() => CleanupHelper.StartCleanup()); }
public MessageSendTests() { _proxy = SettingsManager.GetGmailProxy(); _service = new MessageService(_proxy); _helper = CleanupHelpers.GetMessageServiceCleanupHelper(_service); }