private static bool EnsureSourceExists(EventLogEntrySettings settings, ICakeLog log) { var mgr = new EventLogManager(settings, log); var exists = mgr.SourceExists(); if (exists.HasValue && exists.Value) { return(true); } return(mgr.EnsureSourceExists()); }
public static bool EventSourceExists(this ICakeContext ctx, string sourceName) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (ctx.IsInvalid()) { NotSupported(); } var settings = new EventLogEntrySettings { SourceName = sourceName }; var mgr = new EventLogManager(settings, ctx.Log); var exists = mgr.SourceExists(); return(exists.HasValue && exists.Value); }