Beispiel #1
0
        public static void WriteToEventLog(this ICakeContext ctx, string message)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            if (ctx.IsInvalid())
            {
                NotSupported();
            }
            var settings = new EventLogEntrySettings();
            var mgr      = new EventLogManager(settings, ctx.Log);

            mgr.WriteToEventLog(message);
        }
Beispiel #2
0
        public static bool EventLogExists(this ICakeContext ctx, string logName)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            if (ctx.IsInvalid())
            {
                NotSupported();
            }
            var settings = new EventLogEntrySettings {
                LogName = logName
            };
            var mgr = new EventLogManager(settings, ctx.Log);

            return(mgr.LogExists());
        }
Beispiel #3
0
        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);
        }