Răsfoiți Sursa

2003-07-13 Andreas Nahr <[email protected]>

	* DiagnosticsConfigurationHandler.cs: Removed a never used variable
	* EventLog.cs: Small update to prevent a warning
	* EventLogPermission.cs: Implemented or implementation added
	* EventLogPermissionAttribute.cs: Implemented or implementation added
	* EventLogPermissionEntry.cs: Implemented or implementation added
	* EventLogPermissionEntryCollection.cs: Implemented or implementation added
	* EventLogTraceListener.cs: Implemented or implementation added
	* PerformanceCounterManager.cs: Implemented or implementation added
	* PerformanceCounterInstaller.cs: Made internal
	* PerformanceCounterCategory.cs: Implemented few members
	* PerformanceCounterPermission.cs: Implemented or implementation added
	* PerformanceCounterPermissionAttribute.cs: Implemented or implementation added
	* PerformanceCounterPermissionEntry.cs: Implemented or implementation added
	* PerformanceCounterPermissionEntryCollection.cs: Implemented or implementation added

svn path=/trunk/mcs/; revision=16177
Andreas N 22 ani în urmă
părinte
comite
78dc7ab616

+ 17 - 0
mcs/class/System/System.Diagnostics/ChangeLog

@@ -1,3 +1,20 @@
+2003-07-13  Andreas Nahr <[email protected]>
+
+	* DiagnosticsConfigurationHandler.cs: Removed a never used variable
+	* EventLog.cs: Small update to prevent a warning
+	* EventLogPermission.cs: Implemented or implementation added
+	* EventLogPermissionAttribute.cs: Implemented or implementation added
+	* EventLogPermissionEntry.cs: Implemented or implementation added
+	* EventLogPermissionEntryCollection.cs: Implemented or implementation added
+	* EventLogTraceListener.cs: Implemented or implementation added
+	* PerformanceCounterManager.cs: Implemented or implementation added
+	* PerformanceCounterInstaller.cs: Made internal
+	* PerformanceCounterCategory.cs: Implemented few members
+	* PerformanceCounterPermission.cs: Implemented or implementation added
+	* PerformanceCounterPermissionAttribute.cs: Implemented or implementation added
+	* PerformanceCounterPermissionEntry.cs: Implemented or implementation added
+	* PerformanceCounterPermissionEntryCollection.cs: Implemented or implementation added
+	
 2003-07-07  Andreas Nahr <[email protected]>
 
 	* EventLog.cs: Removed unneccesary attribute according to corecompare

+ 1 - 1
mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs

@@ -274,7 +274,7 @@ namespace System.Diagnostics
 			try {
 				TraceImpl.Listeners.Remove (name);
 			}
-			catch (ArgumentException e) {
+			catch (ArgumentException) {
 				// The specified listener wasn't in the collection
 				// Ignore this; .NET does.
 			}

+ 6 - 0
mcs/class/System/System.Diagnostics/EventLog.cs

@@ -285,6 +285,12 @@ namespace System.Diagnostics {
 			throw new NotImplementedException ();
 		}
 
+		internal void OnEntryWritten (EventLogEntry newEntry)
+		{
+			if (EntryWritten != null)
+				EntryWritten (this, new EntryWrittenEventArgs (newEntry));
+		}
+
 		[MonitoringDescription ("Raised for each eventlog entry written.")]
 		public event EntryWrittenEventHandler EntryWritten;
 	}

+ 29 - 30
mcs/class/System/System.Diagnostics/EventLogPermission.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002 Jonathan Pryor
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -14,37 +16,34 @@ using System.Security.Permissions;
 namespace System.Diagnostics {
 
 	[Serializable]
-	[MonoTODO("Just Stubbed Out")]
-	public class EventLogPermission 
-//		: ResourcePermissionBase
+	public sealed class EventLogPermission : ResourcePermissionBase
 	{
-//		[MonoTODO]
-//		public EventLogPermission()
-//		{
-//		}
-//
-//		[MonoTODO]
-//		public EventLogPermission(
-//			EventLogPermissionEntry[] permissionAccessEntries)
-//		{
-//		}
-//
-//		[MonoTODO]
-//		public EventLogPermission(PermissionState state)
-//		{
-//		}
-//
-//		[MonoTODO]
-//		public EventLogPermission(
-//			EventLogPermissionAccess permissionAccess,
-//			string machineName)
-//		{
-//		}
-//
-//		[MonoTODO]
-//		public EventLogPermissionEntryCollection PermissionEntries {
-//			get {throw new NotImplementedException();}
-//		}
+
+		public EventLogPermission()
+		{
+		}
+
+		public EventLogPermission (EventLogPermissionEntry[] permissionAccessEntries)
+		{
+			if (permissionAccessEntries == null)
+				throw new ArgumentNullException("permissionAccessEntries");
+			foreach (EventLogPermissionEntry entry in permissionAccessEntries)
+				AddPermissionAccess (entry.CreateResourcePermissionBaseEntry ());
+		}
+
+		public EventLogPermission (PermissionState state)
+			: base (state)
+		{
+		}
+
+		public EventLogPermission (EventLogPermissionAccess permissionAccess, string machineName)
+		{
+			AddPermissionAccess (new EventLogPermissionEntry (permissionAccess, machineName).CreateResourcePermissionBaseEntry ());
+		}
+
+		public EventLogPermissionEntryCollection PermissionEntries {
+			get {return new EventLogPermissionEntryCollection (base.GetPermissionEntries()); }
+		}
 	}
 }
 

+ 28 - 16
mcs/class/System/System.Diagnostics/EventLogPermissionAttribute.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -12,36 +14,46 @@ using System.Diagnostics;
 using System.Security;
 using System.Security.Permissions;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
 	[AttributeUsage(
 		AttributeTargets.Assembly | AttributeTargets.Class |
 		AttributeTargets.Struct | AttributeTargets.Constructor |
 		AttributeTargets.Method | AttributeTargets.Event)]
 	[Serializable]
-	[MonoTODO("Just Stubbed Out")]
-	public class EventLogPermissionAttribute : CodeAccessSecurityAttribute {
+	public class EventLogPermissionAttribute : CodeAccessSecurityAttribute 
+	{
+		private string machineName;
+		private EventLogPermissionAccess permissionAccess;
 
 		public EventLogPermissionAttribute(SecurityAction action)
 			: base(action)
 		{
+			machineName = ".";
+			permissionAccess = EventLogPermissionAccess.Browse;
+		}
+
+		// May throw ArgumentException if computer name is invalid
+		public string MachineName {
+			get {return machineName;}
+			set {
+				// TODO check machine name
+				machineName = value;
+			}
+		}
+
+		public EventLogPermissionAccess PermissionAccess {
+			get {return permissionAccess;}
+			set {permissionAccess = value;}
 		}
 
-//		// May throw ArgumentException if computer name is invalid
-//		public string MachineName {
-//			get {throw new NotImplementedException();}
-//			set {throw new NotImplementedException();}
-//		}
-//
-//		public EventLogPermissionAccess PermissionAccess {
-//			get {throw new NotImplementedException();}
-//			set {throw new NotImplementedException();}
-//		}
-//
-		[MonoTODO]
 		public override IPermission CreatePermission()
 		{
-			throw new NotImplementedException();
+			if (base.Unrestricted) {
+				return new EventLogPermission (PermissionState.Unrestricted); 
+			}
+			return new EventLogPermission (PermissionAccess, MachineName); 
 		}
 	}
 }

+ 29 - 20
mcs/class/System/System.Diagnostics/EventLogPermissionEntry.cs

@@ -3,35 +3,44 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
 using System.Diagnostics;
+using System.Security.Permissions;
 
-namespace System.Diagnostics {
-
+namespace System.Diagnostics 
+{
 	[Serializable]
-	[MonoTODO("Just Stubbed Out")]
-	public class EventLogPermissionEntry {
+	public class EventLogPermissionEntry
+	{
+		private EventLogPermissionAccess permissionAccess;
+		private string machineName;
 
-//		[MonoTODO]
-//		public EventLogPermissionEntry(
-//			EventLogPermissionAccess permissionAccess,
-//			string machineName)
-//		{
-//		}
-//
-//		[MonoTODO]
-//		public string MachineName {
-//			get {throw new NotImplementedException();}
-//		}
-//
-//		[MonoTODO]
-//		public EventLogPermissionAccess PermissionAccess {
-//			get {throw new NotImplementedException();}
-//		}
+		public EventLogPermissionEntry (
+			EventLogPermissionAccess permissionAccess,
+			string machineName)
+		{
+			this.permissionAccess = permissionAccess;
+			this.machineName = machineName;
+		}
+
+		public string MachineName {
+			get {return machineName; }
+		}
+
+		public EventLogPermissionAccess PermissionAccess {
+			get {return permissionAccess; }
+		}
+
+		internal ResourcePermissionBaseEntry CreateResourcePermissionBaseEntry ()
+		{
+			return new ResourcePermissionBaseEntry ((int) permissionAccess, new string[] {machineName});
+		} 
 	}
 }
 

+ 86 - 82
mcs/class/System/System.Diagnostics/EventLogPermissionEntryCollection.cs

@@ -1,104 +1,108 @@
 //
-// System.Diagnostics.EventLogEntryCollection.cs
+// System.Diagnostics.EventLogPermissionEntryCollection.cs
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002 Jonathan Pryor
+// (C) 2003 Andreas Nahr
 //
 
 
 using System;
 using System.Collections;
 using System.Diagnostics;
+using System.Security.Permissions;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
-	[MonoTODO]
-	public class EventLogPermissionEntryCollection : CollectionBase {
+	[Serializable]
+	public class EventLogPermissionEntryCollection : CollectionBase 
+	{
+
+		private EventLogPermissionEntryCollection()
+		{
+		}
+
+		internal EventLogPermissionEntryCollection (ResourcePermissionBaseEntry[] entries)
+		{
+			foreach (ResourcePermissionBaseEntry entry in entries) {
+				List.Add (new EventLogPermissionEntry ((EventLogPermissionAccess) entry.PermissionAccess, entry.PermissionAccessPath[0]));
+			}	
+		}
+
+		public virtual EventLogEntry this [int index] {
+			get {return (EventLogEntry) List[index];}
+		}
+
+		public int Add(EventLogPermissionEntry value)
+		{
+			return List.Add (value);
+		}
+
+		public void AddRange(EventLogPermissionEntry[] value)
+		{
+			foreach (EventLogPermissionEntry entry in value)
+				List.Add (entry);
+		}
+
+		public void AddRange(EventLogPermissionEntryCollection value)
+		{
+			foreach (EventLogPermissionEntry entry in value)
+				List.Add (entry);
+		}
+
+		public bool Contains(EventLogPermissionEntry value)
+		{
+			return List.Contains (value);
+		}
+
+		public void CopyTo(EventLogPermissionEntry[] array, int index)
+		{
+			List.CopyTo (array, index);
+		}
+
+		public int IndexOf(EventLogPermissionEntry value)
+		{
+			return List.IndexOf (value);
+		}
+
+		public void Insert(int index, EventLogPermissionEntry value)
+		{
+			List.Insert (index, value);
+		}
 
 		[MonoTODO]
-		internal EventLogPermissionEntryCollection()
+		protected override void OnClear()
 		{
+			throw new NotImplementedException();
 		}
 
-//		[MonoTODO]
-//		public virtual EventLogEntry this [int index] {
-//			get {throw new NotImplementedException();}
-//		}
-//
-//		[MonoTODO]
-//		public int Add(EventLogPermissionEntry value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public void AddRange(EventLogPermissionEntry[] value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public void AddRange(EventLogPermissionEntryCollection value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public bool Contains(EventLogPermissionEntry value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public void CopyTo(EventLogPermissionEntry[] array, int index)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public int IndexOf(EventLogPermissionEntry value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public void Insert(int index, EventLogPermissionEntry value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		protected override void OnClear()
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		protected override void OnInsert(int index, object value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		protected override void OnRemove(int index, object value)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		protected override void OnSet(int index, object oldValue, 
-//			object newValue)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public void Remove(EventLogPermissionEntry value)
-//		{
-//			throw new NotImplementedException();
-//		}
+		[MonoTODO]
+		protected override void OnInsert(int index, object value)
+		{
+			throw new NotImplementedException();
+		}
+
+		[MonoTODO]
+		protected override void OnRemove(int index, object value)
+		{
+			throw new NotImplementedException();
+		}
+
+		[MonoTODO]
+		protected override void OnSet(int index, object oldValue, 
+			object newValue)
+		{
+			throw new NotImplementedException();
+		}
+
+		public void Remove(EventLogPermissionEntry value)
+		{
+			List.Remove (value);
+		}
 	}
 }
 

+ 46 - 47
mcs/class/System/System.Diagnostics/EventLogTraceListener.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002 Jonathan Pryor
+// (C) 2003 Andreas Nahr
 //
 
 
@@ -12,61 +14,58 @@ using System;
 using System.Collections;
 using System.Diagnostics;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
-	[MonoTODO]
-	public class EventLogTraceListener : TraceListener {
+	public class EventLogTraceListener : TraceListener 
+	{
+		private EventLog eventLog;
+		private string source;
+
+		public EventLogTraceListener ()
+		{
+		}
+
+		public EventLogTraceListener (EventLog eventLog)
+		{
+			this.eventLog = eventLog;
+		}
+
+		public EventLogTraceListener (string source)
+		{
+			this.source = source;
+		}
+
+		public EventLog EventLog {
+			get {return eventLog;}
+			set {eventLog = value;}
+		}
+
+		public override string Name {
+			get {return source;}
+			set {source = value;}
+		}
+
+		[MonoTODO]
+		public override void Close ()
+		{
+			throw new NotImplementedException();
+		}
+
+		[MonoTODO]
+		protected override void Dispose (bool disposing)
+		{
+			throw new NotImplementedException();
+		}
 
-//		[MonoTODO]
-//		public EventLogTraceListener()
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public EventLogTraceListener(EventLog eventLog)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public EventLogTraceListener(string source)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		public EventLog EventLog {
-//			get {throw new NotImplementedException();}
-//			set {throw new NotImplementedException();}
-//		}
-//
-//		[MonoTODO]
-//		public override string Name {
-//			get {throw new NotImplementedException();}
-//			set {throw new NotImplementedException();}
-//		}
-//
-//		[MonoTODO]
-//		public override void Close()
-//		{
-//			throw new NotImplementedException();
-//		}
-//
-//		[MonoTODO]
-//		protected override void Dispose(bool disposing)
-//		{
-//			throw new NotImplementedException();
-//		}
-//
 		[MonoTODO]
-		public override void Write(string message)
+		public override void Write (string message)
 		{
 			throw new NotImplementedException();
 		}
 
 		[MonoTODO]
-		public override void WriteLine(string message)
+		public override void WriteLine (string message)
 		{
 			throw new NotImplementedException();
 		}

+ 176 - 165
mcs/class/System/System.Diagnostics/PerformanceCounterCategory.cs

@@ -10,173 +10,184 @@
 using System;
 using System.Diagnostics;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
-	public class PerformanceCounterCategory {
+	public sealed class PerformanceCounterCategory 
+	{
+		private string categoryName;
+		private string machineName;
 
-//		[MonoTODO]
-//		public PerformanceCounterCategory ()
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		// may throw ArgumentException (""), ArgumentNullException
-//		[MonoTODO]
-//		public PerformanceCounterCategory (string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		// may throw ArgumentException (""), ArgumentNullException
-//		[MonoTODO]
-//		public PerformanceCounterCategory (string categoryName,
-//			string machineName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		// may throw InvalidOperationException, Win32Exception
-//		[MonoTODO]
-//		public string CategoryHelp {
-//			get {throw new NotImplementedException ();}
-//		}
-//
-//		// may throw ArgumentException (""), ArgumentNullException
-//		[MonoTODO]
-//		public string CategoryName {
-//			get {throw new NotImplementedException ();}
-//			set {throw new NotImplementedException ();}
-//		}
-//
-//		// may throw ArgumentException
-//		[MonoTODO]
-//		public string MachineName {
-//			get {throw new NotImplementedException ();}
-//			set {throw new NotImplementedException ();}
-//		}
-//
-//		// may throw ArgumentNullException, InvalidOperationException
-//		// (categoryName isn't set), Win32Exception
-//		[MonoTODO]
-//		public bool CounterExists (string counterName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		// may throw ArgumentNullException, InvalidOperationException
-//		// (categoryName is ""), Win32Exception
-//		[MonoTODO]
-//		public bool CounterExists (string counterName, 
-//			string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		// may throw ArgumentNullException, InvalidOperationException
-//		// (categoryName is "", machine name is bad), Win32Exception
-//		[MonoTODO]
-//		public bool CounterExists (string counterName, 
-//			string categoryName,
-//			string machineName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static PerformanceCounterCategory Create (
-//			string categoryName,
-//			string categoryHelp,
-//			CounterCreationDataCollection counterData)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static PerformanceCounterCategory Create (
-//			string categoryName,
-//			string categoryHelp,
-//			string counterName,
-//			string counterHelp)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static void Delete (string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static bool Exists (string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static bool Exists (string categoryName, 
-//			string machineName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static PerformanceCounterCategory[] GetCategories ()
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public static PerformanceCounterCategory[] GetCategories (
-//			string machineName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public PerformanceCounter[] GetCounters ()
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public PerformanceCounter[] GetCounters (string instanceName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public string[] GetInstanceNames ()
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public bool InstanceExists (string instanceName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public bool InstanceExists (string instanceName, 
-//			string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public bool InstanceExists (string instanceName, 
-//			string categoryName,
-//			string machineName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public InstanceDataCollectionCollection ReadCategory ()
-//		{
-//			throw new NotImplementedException ();
-//		}
+		public PerformanceCounterCategory ()
+			: this ("", ".")
+		{
+		}
+
+		// may throw ArgumentException (""), ArgumentNullException
+		public PerformanceCounterCategory (string categoryName)
+			: this (categoryName, ".")
+		{
+		}
+
+		// may throw ArgumentException (""), ArgumentNullException
+		[MonoTODO]
+		public PerformanceCounterCategory (string categoryName,
+			string machineName)
+		{
+			// TODO checks and whatever else is needed
+			this.categoryName = categoryName;
+			this.machineName = machineName;
+			throw new NotImplementedException ();
+		}
+
+		// may throw InvalidOperationException, Win32Exception
+		[MonoTODO]
+		public string CategoryHelp {
+			get {throw new NotImplementedException ();}
+		}
+
+		// may throw ArgumentException (""), ArgumentNullException
+		[MonoTODO]
+		public string CategoryName {
+			get {return categoryName;}
+			set {
+				// TODO needs validity checks
+				categoryName = value;
+			}
+		}
+
+		// may throw ArgumentException
+		[MonoTODO]
+		public string MachineName {
+			get {return machineName;}
+			set {
+				// TODO needs validity checks
+				machineName = value;
+			}
+		}
+
+		// may throw ArgumentNullException, InvalidOperationException
+		// (categoryName isn't set), Win32Exception
+		[MonoTODO]
+		public bool CounterExists (string counterName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		// may throw ArgumentNullException, InvalidOperationException
+		// (categoryName is ""), Win32Exception
+		[MonoTODO]
+		public bool CounterExists (string counterName, 
+			string categoryName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		// may throw ArgumentNullException, InvalidOperationException
+		// (categoryName is "", machine name is bad), Win32Exception
+		[MonoTODO]
+		public bool CounterExists (string counterName, 
+			string categoryName,
+			string machineName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static PerformanceCounterCategory Create (
+			string categoryName,
+			string categoryHelp,
+			CounterCreationDataCollection counterData)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static PerformanceCounterCategory Create (
+			string categoryName,
+			string categoryHelp,
+			string counterName,
+			string counterHelp)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static void Delete (string categoryName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static bool Exists (string categoryName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static bool Exists (string categoryName, 
+			string machineName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static PerformanceCounterCategory[] GetCategories ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static PerformanceCounterCategory[] GetCategories (
+			string machineName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public PerformanceCounter[] GetCounters ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public PerformanceCounter[] GetCounters (string instanceName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public string[] GetInstanceNames ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool InstanceExists (string instanceName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool InstanceExists (string instanceName, 
+			string categoryName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public bool InstanceExists (string instanceName, 
+			string categoryName,
+			string machineName)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public InstanceDataCollectionCollection ReadCategory ()
+		{
+			throw new NotImplementedException ();
+		}
 	}
 }
 

+ 1 - 1
mcs/class/System/System.Diagnostics/PerformanceCounterInstaller.cs

@@ -15,7 +15,7 @@ using System.ComponentModel;
 
 namespace System.Diagnostics {
 
-	public class PerformanceCounterInstaller {
+	internal class PerformanceCounterInstaller {
 
 //		[MonoTODO]
 //		public PerformanceCounterInstaller ()

+ 7 - 8
mcs/class/System/System.Diagnostics/PerformanceCounterManager.cs

@@ -14,15 +14,14 @@ using System.Runtime.InteropServices;
 namespace System.Diagnostics {
 
 	[ComVisible(true)]
-	// [Guid("")]
-	public class PerformanceCounterManager : ICollectData {
+	[Guid("82840be1-d273-11d2-b94a-00600893b17a")]
+	public sealed class PerformanceCounterManager : ICollectData {
+
+		[MonoTODO]
+		public PerformanceCounterManager ()
+		{
+		}
 
-//		[MonoTODO]
-//		public PerformanceCounterManager ()
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
 		[MonoTODO]
 		void ICollectData.CloseData ()
 		{

+ 32 - 26
mcs/class/System/System.Diagnostics/PerformanceCounterPermission.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -13,33 +15,37 @@ using System.Security.Permissions;
 
 namespace System.Diagnostics {
 
-	public class PerformanceCounterPermission : ResourcePermissionBase {
+	[Serializable]
+	public sealed class PerformanceCounterPermission : ResourcePermissionBase {
 
-//		public PerformaceCounterPermission ()
-//		{
-//		}
-//
-//		public PerformaceCounterPermission (
-//			PerformanceCounterPermissionEntry[] 
-//				permissionAccessEntries)
-//		{
-//		}
-//
-//		public PerformaceCounterPermission (PermissionState state)
-//		{
-//		}
-//
-//		public PerformaceCounterPermission (
-//			PerformanceCounterPermissionAccess permissionAccess, 
-//			string machineName, 
-//			string categoryName)
-//		{
-//		}
-//
-//		public PerformanceCounterPermissionEntryCollection 
-//			PermissionEntries {
-//			get {throw new NotImplementedException ();}
-//		}
+		public PerformanceCounterPermission ()
+		{
+		}
+
+		public PerformanceCounterPermission (PerformanceCounterPermissionEntry[] permissionAccessEntries)
+		{
+			if (permissionAccessEntries == null)
+				throw new ArgumentNullException("permissionAccessEntries");
+			foreach (PerformanceCounterPermissionEntry entry in permissionAccessEntries)
+				AddPermissionAccess (entry.CreateResourcePermissionBaseEntry ());
+		}
+
+		public PerformanceCounterPermission (PermissionState state)
+			: base (state)
+		{
+		}
+
+		public PerformanceCounterPermission (
+			PerformanceCounterPermissionAccess permissionAccess, 
+			string machineName, 
+			string categoryName)
+		{
+			AddPermissionAccess (new PerformanceCounterPermissionEntry (permissionAccess, machineName, categoryName).CreateResourcePermissionBaseEntry ());
+		}
+
+		public PerformanceCounterPermissionEntryCollection PermissionEntries {
+			get {return new PerformanceCounterPermissionEntryCollection (base.GetPermissionEntries()); }
+		}
 	}
 }
 

+ 37 - 28
mcs/class/System/System.Diagnostics/PerformanceCounterPermissionAttribute.cs

@@ -3,8 +3,10 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -12,7 +14,8 @@ using System.Diagnostics;
 using System.Security;
 using System.Security.Permissions;
 
-namespace System.Diagnostics {
+namespace System.Diagnostics 
+{
 
 	[AttributeUsage(
 		AttributeTargets.Assembly |
@@ -21,40 +24,46 @@ namespace System.Diagnostics {
 		AttributeTargets.Constructor |
 		AttributeTargets.Method |
 		AttributeTargets.Event )]
-	[MonoTODO]
-	public class PerformanceCounterPermissionAttribute 
-		: CodeAccessSecurityAttribute {
+	[Serializable]
+	public class PerformanceCounterPermissionAttribute : CodeAccessSecurityAttribute 
+	{
+		private string categoryName;
+		private string machineName;
+		private PerformanceCounterPermissionAccess permissionAccess;
 
-		[MonoTODO]
-		public PerformanceCounterPermissionAttribute (
-			SecurityAction action) 
+		public PerformanceCounterPermissionAttribute (SecurityAction action) 
 			: base (action)
 		{
-			throw new NotImplementedException ();
+			categoryName = "*";
+			machineName = ".";
+			permissionAccess = PerformanceCounterPermissionAccess.Browse;
+		}
+
+		public string CategoryName {
+			get {return categoryName;}
+			set {categoryName = value;}
+		}
+
+		// May throw ArgumentException if computer name is invalid
+		public string MachineName {
+			get {return machineName;}
+			set {
+				// TODO check machine name
+				machineName = value;
+			}
+		}
+
+		public PerformanceCounterPermissionAccess PermissionAccess {
+			get {return permissionAccess;}
+			set {permissionAccess = value;}
 		}
 
-//		[MonoTODO]
-//		public string CategoryName {
-//			get {throw new NotImplementedException ();}
-//			set {throw new NotImplementedException ();}
-//		}
-//
-//		[MonoTODO]
-//		public string MachineName {
-//			get {throw new NotImplementedException ();}
-//			set {throw new NotImplementedException ();}
-//		}
-//
-//		[MonoTODO]
-//		public PerformanceCounterPermissionAccess PermissionAccess {
-//			get {throw new NotImplementedException ();}
-//			set {throw new NotImplementedException ();}
-//		}
-//
-		[MonoTODO]
 		public override IPermission CreatePermission ()
 		{
-			throw new NotImplementedException ();
+			if (base.Unrestricted) {
+				return new PerformanceCounterPermission (PermissionState.Unrestricted); 
+			}
+			return new PerformanceCounterPermission (PermissionAccess, MachineName, categoryName); 
 		}
 	}
 }

+ 37 - 28
mcs/class/System/System.Diagnostics/PerformanceCounterPermissionEntry.cs

@@ -3,42 +3,51 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
 using System.Diagnostics;
+using System.Security.Permissions;
 
-namespace System.Diagnostics {
-
+namespace System.Diagnostics 
+{
 	[Serializable]
-	[MonoTODO]
-	public class PerformanceCounterPermissionEntry {
-
-//		[MonoTODO]
-//		public PerformanceCounterPermissionEntry (
-//			PerformanceCounterPermissionAccess permissionAccess,
-//			string machineName,
-//			string categoryName)
-//		{
-//			throw new NotImplementedException ();
-//		}
-//
-//		[MonoTODO]
-//		public string CategoryName {
-//			get {throw new NotImplementedException ();}
-//		}
-//
-//		[MonoTODO]
-//		public string MachineName {
-//			get {throw new NotImplementedException ();}
-//		}
-//
-//		[MonoTODO]
-//		public PerformanceCounterPermissionAccess PermissionAccess {
-//			get {throw new NotImplementedException ();}
-//		}
+	public class PerformanceCounterPermissionEntry 
+	{
+		private PerformanceCounterPermissionAccess permissionAccess;
+		private string machineName;
+		private string categoryName;
+
+		public PerformanceCounterPermissionEntry (
+			PerformanceCounterPermissionAccess permissionAccess,
+			string machineName,
+			string categoryName)
+		{
+			this.permissionAccess = permissionAccess;
+			this.machineName = machineName;
+			this.categoryName = categoryName;
+		}
+
+		public string CategoryName {
+			get {return categoryName; }
+		}
+
+		public string MachineName {
+			get {return machineName; }
+		}
+
+		public PerformanceCounterPermissionAccess PermissionAccess {
+			get {return permissionAccess; }
+		}
+
+		internal ResourcePermissionBaseEntry CreateResourcePermissionBaseEntry ()
+		{
+			return new ResourcePermissionBaseEntry ((int) permissionAccess, new string[] {machineName, categoryName});
+		} 
 	}
 }
 

+ 8 - 3
mcs/class/System/System.Diagnostics/PerformanceCounterPermissionEntryCollection.cs

@@ -3,23 +3,28 @@
 //
 // Authors:
 //   Jonathan Pryor ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002
+// (C) 2003 Andreas Nahr
 //
 
 using System;
 using System.Diagnostics;
 using System.Collections;
 using System.Globalization;
+using System.Security.Permissions;
 
 namespace System.Diagnostics {
 
 	[Serializable]
-	public class PerformanceCounterPermissionEntryCollection 
-		: CollectionBase 
+	public class PerformanceCounterPermissionEntryCollection : CollectionBase 
 	{
-		internal PerformanceCounterPermissionEntryCollection ()
+		internal PerformanceCounterPermissionEntryCollection (ResourcePermissionBaseEntry[] entries)
 		{
+			foreach (ResourcePermissionBaseEntry entry in entries) {
+				List.Add (new PerformanceCounterPermissionEntry ((PerformanceCounterPermissionAccess) entry.PermissionAccess, entry.PermissionAccessPath[0], entry.PermissionAccessPath[1]));
+			}	
 		}
 
 		public PerformanceCounterPermissionEntry this [int index] {