Example #1
0
        public static bool SourceExists(string source, string machineName)
        {
            if (machineName == null || machineName.Trim().Length == 0)
            {
                throw new ArgumentException(string.Format(
                                                CultureInfo.InvariantCulture, "Invalid value '{0}' for"
                                                + " parameter 'machineName'.", machineName));
            }

            EventLogImpl impl = CreateEventLogImpl(string.Empty, machineName,
                                                   source);

            return(impl.SourceExists(source, machineName));
        }
Example #2
0
        public static string LogNameFromSourceName(string source, string machineName)
        {
            if (machineName == null || machineName.Trim().Length == 0)
#if NET_2_0
            { throw new ArgumentException(string.Format(
                                              CultureInfo.InvariantCulture, "Invalid value '{0}' for"
                                              + " parameter 'MachineName'.", machineName)); }
#else
            { throw new ArgumentException(string.Format(
                                              CultureInfo.InvariantCulture, "Invalid value {0} for"
                                              + " parameter MachineName.", machineName)); }
#endif

            EventLogImpl impl = CreateEventLogImpl(string.Empty, machineName,
                                                   source);
            return(impl.LogNameFromSourceName(source, machineName));
        }
Example #3
0
        public static bool Exists(string logName, string machineName)
        {
            if (machineName == null || machineName.Trim().Length == 0)
            {
                throw new ArgumentException("Invalid format for argument machineName.");
            }

            if (logName == null || logName.Length == 0)
            {
                return(false);
            }

            EventLogImpl impl = CreateEventLogImpl(logName, machineName,
                                                   string.Empty);

            return(impl.Exists(logName, machineName));
        }
Example #4
0
        public static void Delete(string logName, string machineName)
        {
            if (machineName == null || machineName.Trim().Length == 0)
            {
                throw new ArgumentException("Invalid format for argument"
                                            + " machineName.");
            }

            if (logName == null || logName.Length == 0)
            {
                throw new ArgumentException("Log to delete was not specified.");
            }

            EventLogImpl impl = CreateEventLogImpl(logName, machineName,
                                                   string.Empty);

            impl.Delete(logName, machineName);
        }
Example #5
0
        public EventLog(string logName, string machineName, string source)
        {
            if (logName == null)
            {
                throw new ArgumentNullException("logName");
            }
            if (machineName == null || machineName.Trim().Length == 0)
            {
                throw new ArgumentException(string.Format(
                                                CultureInfo.InvariantCulture, "Invalid value '{0}' for"
                                                + " parameter 'machineName'.", machineName));
            }

            this.source      = source;
            this.machineName = machineName;
            this.logName     = logName;

            Impl = CreateEventLogImpl(this);
        }
Example #6
0
        static void CreateEventSource(EventSourceCreationData sourceData)
        {
            if (sourceData.Source == null || sourceData.Source.Length == 0)
            {
                throw new ArgumentException("Source property value has not been specified.");
            }

            if (sourceData.LogName == null || sourceData.LogName.Length == 0)
            {
                throw new ArgumentException("Log property value has not been specified.");
            }

            if (SourceExists(sourceData.Source, sourceData.MachineName))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          "Source '{0}' already exists on '{1}'.", sourceData.Source,
                                                          sourceData.MachineName));
            }

            EventLogImpl impl = CreateEventLogImpl(sourceData.LogName,
                                                   sourceData.MachineName, sourceData.Source);

            impl.CreateEventSource(sourceData);
        }
Example #7
0
 internal EventLogEntryEnumerator(EventLogImpl impl)
 {
     _impl = impl;
 }
Example #8
0
 internal EventLogEntryCollection(EventLogImpl impl)
 {
     _impl = impl;
 }
Example #9
0
        public static EventLog[] GetEventLogs(string machineName)
        {
            EventLogImpl impl = CreateEventLogImpl(new EventLog());

            return(impl.GetEventLogs(machineName));
        }
Example #10
0
		public EventLog(string logName, string machineName, string source)
		{
			if (logName == null) {
				throw new ArgumentNullException ("logName");
			}
			if (machineName == null || machineName.Trim ().Length == 0)
				throw new ArgumentException (string.Format (
					CultureInfo.InvariantCulture, "Invalid value '{0}' for"
					+ " parameter 'machineName'.", machineName));

			this.source = source;
			this.machineName = machineName;
			this.logName = logName;

			Impl = CreateEventLogImpl (this);
		}
			internal EventLogEntryEnumerator (EventLogImpl impl)
			{
				_impl = impl;
			}
		internal EventLogEntryCollection(EventLogImpl impl)
		{
			_impl = impl;
		}