Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2004-04-06 23:05:13 +0400
committerLluis Sanchez <lluis@novell.com>2004-04-06 23:05:13 +0400
commit14c59cfad1a213b3858b79497af4bee7e62e0a55 (patch)
treef1df0f60338f4ccf041c7a767bb7153b77bbe2e8 /mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
parent8f63d91200821d67e4a3d4495b3eb30818b51a53 (diff)
* DiagnosticsConfigurationHandler.cs: If initializeData is provided, use the
constructor that only takes one string as parameter to construct the listener. The name is set using the Name property, not the constructor. * TextWriterTraceListener.cs: In Write*, do nothing if no writer was provided. svn path=/trunk/mcs/; revision=25105
Diffstat (limited to 'mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs')
-rw-r--r--mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs32
1 files changed, 20 insertions, 12 deletions
diff --git a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
index 706ce06c4a9..8ad3817dd8c 100644
--- a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
+++ b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs
@@ -253,20 +253,28 @@ namespace System.Diagnostics
private void AddTraceListener (string name, string type, string initializeData)
{
Type t = Type.GetType (type);
- object[] args = null;
- if (initializeData == null)
- args = new object[]{name};
- else
- args = new object[]{initializeData, name};
- try {
- TraceListener l = (TraceListener) Activator.CreateInstance (t, args);
- TraceImpl.Listeners.Add (l);
+ if (t == null)
+ throw new ConfigurationException (string.Format ("Invalid Type Specified: {0}", type));
+
+ object[] args;
+ Type[] types;
+
+ if (initializeData != null) {
+ args = new object[] { initializeData };
+ types = new Type[] { typeof(string) };
}
- catch (Exception e) {
- throw new ConfigurationException (
- string.Format ("Invalid Type Specified: {0}", type),
- e);
+ else {
+ args = null;
+ types = new Type[0];
}
+
+ System.Reflection.ConstructorInfo ctor = t.GetConstructor (types);
+ if (ctor == null)
+ throw new ConfigurationException ("Couldn't find constructor for class " + type);
+
+ TraceListener l = (TraceListener) ctor.Invoke (args);
+ l.Name = name;
+ TraceImpl.Listeners.Add (l);
}
private void RemoveTraceListener (string name)