Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
//
// System.Diagnostics.AlphabeticalEnumConverter.cs
//
// Authors:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
namespace System.Diagnostics
{
internal sealed class AlphabeticalEnumConverter : EnumConverter
{
public AlphabeticalEnumConverter (Type type)
: base (type)
{
}
[MonoTODO ("Create sorted standart values")]
public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
{
return Values;
}
}
}

View File

@@ -0,0 +1,79 @@
//
// System.Diagnostics.BooleanSwitch.cs
//
// Author:
// John R. Hicks (angryjohn69@nc.rr.com)
// Jonathan Pryor (jonpryor@vt.edu)
//
// (C) 2001-2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Globalization;
namespace System.Diagnostics
{
/// <summary>
/// Provides a simple on/off switch that controls debugging
/// and tracing output
/// </summary>
[SwitchLevel (typeof (bool))]
public class BooleanSwitch : Switch
{
/// <summary>
/// Initializes a new instance
/// </summary>
public BooleanSwitch(string displayName, string description)
: base(displayName, description)
{
}
/// <summary>
/// Initializes a new instance
/// </summary>
public BooleanSwitch(string displayName, string description, string defaultSwitchValue)
: base(displayName, description, defaultSwitchValue)
{
}
/// <summary>
/// Specifies whether the switch is enabled or disabled
/// </summary>
public bool Enabled {
// On .NET, any non-zero value is true. Only 0 is false.
get {return SwitchSetting != 0;}
set {
SwitchSetting = Convert.ToInt32(value);
}
}
protected override void OnValueChanged ()
{
int i;
if (int.TryParse (Value, out i))
Enabled = i != 0;
else
Enabled = Convert.ToBoolean (Value);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
//
// System.Diagnostics.ConsoleTraceListener.cs
//
// Authors:
// Ben Maurer <bmaurer@andrew.cmu.edu>
//
// (C) 2006 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Diagnostics {
public class ConsoleTraceListener : TextWriterTraceListener {
public ConsoleTraceListener () : this (false) {}
public ConsoleTraceListener (bool useErrorStream) :
base (useErrorStream ? Console.Error : Console.Out) {}
internal ConsoleTraceListener (string data) :
this (Convert.ToBoolean (data)) {}
}
}

View File

@@ -0,0 +1,69 @@
//
// CorrelationManager.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
namespace System.Diagnostics
{
public class CorrelationManager
{
Guid activity;
Stack op_stack = new Stack ();
internal CorrelationManager ()
{
}
public Guid ActivityId {
get { return activity; }
set { activity = value; }
}
public Stack LogicalOperationStack {
get { return op_stack; }
}
public void StartLogicalOperation ()
{
StartLogicalOperation (Guid.NewGuid ());
}
public void StartLogicalOperation (object operationId)
{
op_stack.Push (operationId);
}
public void StopLogicalOperation ()
{
op_stack.Pop ();
}
}
}

View File

@@ -0,0 +1,100 @@
//
// System.Diagnostics.CounterCreationData.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002
// (C) 2003 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
namespace System.Diagnostics {
[Serializable]
[TypeConverter ("System.Diagnostics.Design.CounterCreationDataConverter, " + Consts.AssemblySystem_Design)]
public class CounterCreationData
{
// keep the same order of fields: this is used in metadata/mono-perfcounters.c
private string help = String.Empty;
private string name;
private PerformanceCounterType type;
public CounterCreationData ()
{
}
public CounterCreationData (string counterName,
string counterHelp,
PerformanceCounterType counterType)
{
CounterName = counterName;
CounterHelp = counterHelp;
CounterType = counterType;
}
[DefaultValue ("")]
[MonitoringDescription ("Description of this counter.")]
public string CounterHelp {
get {return help;}
set {
if (value == null)
throw new ArgumentNullException ("value");
help = value;
}
}
[DefaultValue ("")]
[MonitoringDescription ("Name of this counter.")]
[TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
public string CounterName
{
get {return name;}
set {
if (value == null)
throw new ArgumentNullException ("value");
if (value == "")
throw new ArgumentException ("value");
name = value;
}
}
// may throw InvalidEnumArgumentException
[DefaultValue (typeof (PerformanceCounterType), "NumberOfItems32")]
[MonitoringDescription ("Type of this counter.")]
public PerformanceCounterType CounterType {
get {return type;}
set {
if (!Enum.IsDefined (typeof (PerformanceCounterType), value))
throw new InvalidEnumArgumentException ();
type = value;
}
}
}
}

View File

@@ -0,0 +1,118 @@
//
// System.Diagnostics.CounterCreationDataCollection.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
// (C) 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
namespace System.Diagnostics {
[Serializable]
public class CounterCreationDataCollection : CollectionBase {
public CounterCreationDataCollection ()
{
}
public CounterCreationDataCollection (
CounterCreationData[] value)
{
AddRange (value);
}
public CounterCreationDataCollection (
CounterCreationDataCollection value)
{
AddRange (value);
}
public CounterCreationData this [int index] {
get {return (CounterCreationData) InnerList[index];}
set {InnerList[index] = value;}
}
public int Add (CounterCreationData value)
{
return InnerList.Add (value);
}
public void AddRange (CounterCreationData[] value)
{
foreach (CounterCreationData v in value)
{
Add (v);
}
}
public void AddRange (CounterCreationDataCollection value)
{
foreach (CounterCreationData v in value)
{
Add (v);
}
}
public bool Contains (CounterCreationData value)
{
return InnerList.Contains (value);
}
public void CopyTo (CounterCreationData[] array, int index)
{
InnerList.CopyTo (array, index);
}
public int IndexOf (CounterCreationData value)
{
return InnerList.IndexOf (value);
}
public void Insert (int index, CounterCreationData value)
{
InnerList.Insert (index, value);
}
protected override void OnValidate (object value)
{
if (!(value is CounterCreationData))
throw new NotSupportedException (Locale.GetText(
"You can only insert " +
"CounterCreationData objects into " +
"the collection"));
}
public virtual void Remove (CounterCreationData value)
{
InnerList.Remove (value);
}
}
}

View File

@@ -0,0 +1,171 @@
//
// System.Diagnostics.CounterSample.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002
// (C) 2003 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Diagnostics {
public struct CounterSample {
// do not reorder and keep in sync with the runtime
// in metadata/mono-perfcounters.c
private long rawValue;
private long baseValue;
private long counterFrequency;
private long systemFrequency;
private long timeStamp;
private long timeStamp100nSec;
private long counterTimeStamp;
private PerformanceCounterType counterType;
public CounterSample (long rawValue,
long baseValue,
long counterFrequency,
long systemFrequency,
long timeStamp,
long timeStamp100nSec,
PerformanceCounterType counterType)
: this (rawValue, baseValue, counterFrequency,
systemFrequency, timeStamp, timeStamp100nSec,
counterType, 0)
{
}
public CounterSample (long rawValue,
long baseValue,
long counterFrequency,
long systemFrequency,
long timeStamp,
long timeStamp100nSec,
PerformanceCounterType counterType,
long counterTimeStamp)
{
this.rawValue = rawValue;
this.baseValue = baseValue;
this.counterFrequency = counterFrequency;
this.systemFrequency = systemFrequency;
this.timeStamp = timeStamp;
this.timeStamp100nSec = timeStamp100nSec;
this.counterType = counterType;
this.counterTimeStamp = counterTimeStamp;
}
public static CounterSample Empty = new CounterSample (
0, 0, 0, 0, 0, 0,
PerformanceCounterType.NumberOfItems32,
0);
public long BaseValue {
get {return baseValue;}
}
public long CounterFrequency {
get {return counterFrequency;}
}
public long CounterTimeStamp {
get {return counterTimeStamp;}
}
public PerformanceCounterType CounterType {
get {return counterType;}
}
public long RawValue {
get {return rawValue;}
}
public long SystemFrequency {
get {return systemFrequency;}
}
public long TimeStamp {
get {return timeStamp;}
}
public long TimeStamp100nSec {
get {return timeStamp100nSec;}
}
public static float Calculate (CounterSample counterSample)
{
return CounterSampleCalculator.ComputeCounterValue (counterSample);
}
public static float Calculate (CounterSample counterSample,
CounterSample nextCounterSample)
{
return CounterSampleCalculator.ComputeCounterValue (counterSample, nextCounterSample);
}
public override bool Equals (object obj)
{
if (!(obj is CounterSample))
return false;
return Equals ((CounterSample) obj);
}
public bool Equals (CounterSample other)
{
return
rawValue == other.rawValue &&
baseValue == other.counterFrequency &&
counterFrequency == other.counterFrequency &&
systemFrequency == other.systemFrequency &&
timeStamp == other.timeStamp &&
timeStamp100nSec == other.timeStamp100nSec &&
counterTimeStamp == other.counterTimeStamp &&
counterType == other.counterType;
}
public static bool operator == (CounterSample obj1, CounterSample obj2)
{
return obj1.Equals (obj2);
}
public static bool operator != (CounterSample obj1, CounterSample obj2)
{
return !obj1.Equals (obj2);
}
public override int GetHashCode ()
{
return (int) (rawValue << 28 ^
(baseValue << 24 ^
(counterFrequency << 20 ^
(systemFrequency << 16 ^
(timeStamp << 8 ^
(timeStamp100nSec << 4 ^
(counterTimeStamp ^
(int) counterType)))))));
}
}
}

View File

@@ -0,0 +1,104 @@
//
// System.Diagnostics.CounterSampleCalculator.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002
// (C) 2003 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Diagnostics {
public static class CounterSampleCalculator {
public static float ComputeCounterValue (CounterSample newSample)
{
switch (newSample.CounterType) {
case PerformanceCounterType.RawFraction:
case PerformanceCounterType.NumberOfItems32:
case PerformanceCounterType.NumberOfItemsHEX32:
case PerformanceCounterType.NumberOfItems64:
case PerformanceCounterType.NumberOfItemsHEX64:
return (float)newSample.RawValue;
default:
return 0;
}
}
[MonoTODO("What's the algorithm?")]
public static float ComputeCounterValue (CounterSample oldSample,
CounterSample newSample)
{
if (newSample.CounterType != oldSample.CounterType)
throw new Exception ("The counter samples must be of the same type");
switch (newSample.CounterType) {
case PerformanceCounterType.RawFraction:
case PerformanceCounterType.NumberOfItems32:
case PerformanceCounterType.NumberOfItemsHEX32:
case PerformanceCounterType.NumberOfItems64:
case PerformanceCounterType.NumberOfItemsHEX64:
return (float)newSample.RawValue;
case PerformanceCounterType.AverageCount64:
return (float)(newSample.RawValue - oldSample.RawValue)/(float)(newSample.BaseValue - oldSample.BaseValue);
case PerformanceCounterType.AverageTimer32:
return (((float)(newSample.RawValue - oldSample.RawValue))/newSample.SystemFrequency)/(float)(newSample.BaseValue - oldSample.BaseValue);
case PerformanceCounterType.CounterDelta32:
case PerformanceCounterType.CounterDelta64:
return (float)(newSample.RawValue - oldSample.RawValue);
case PerformanceCounterType.CounterMultiTimer:
return ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp) * 100.0f/newSample.BaseValue;
case PerformanceCounterType.CounterMultiTimer100Ns:
return ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp100nSec - oldSample.TimeStamp100nSec) * 100.0f/newSample.BaseValue;
case PerformanceCounterType.CounterMultiTimerInverse:
return (newSample.BaseValue - ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp)) * 100.0f;
case PerformanceCounterType.CounterMultiTimer100NsInverse:
return (newSample.BaseValue - ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp100nSec - oldSample.TimeStamp100nSec)) * 100.0f;
case PerformanceCounterType.CounterTimer:
case PerformanceCounterType.CountPerTimeInterval32:
case PerformanceCounterType.CountPerTimeInterval64:
return ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp);
case PerformanceCounterType.CounterTimerInverse:
return (1.0f - ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp100nSec - oldSample.TimeStamp100nSec)) * 100.0f;
case PerformanceCounterType.ElapsedTime:
// FIXME
return 0;
case PerformanceCounterType.Timer100Ns:
return ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp) * 100.0f;
case PerformanceCounterType.Timer100NsInverse:
return (1f - ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp)) * 100.0f;
case PerformanceCounterType.RateOfCountsPerSecond32:
case PerformanceCounterType.RateOfCountsPerSecond64:
return ((float)(newSample.RawValue - oldSample.RawValue))/(float)(newSample.TimeStamp - oldSample.TimeStamp) * 10000000;
default:
Console.WriteLine ("Counter type {0} not handled", newSample.CounterType);
return 0;
}
}
}
}

View File

@@ -0,0 +1,45 @@
//
// DataReceivedEventArgs.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Diagnostics
{
public class DataReceivedEventArgs : EventArgs
{
string data;
internal DataReceivedEventArgs (string data)
{
this.data = data;
}
public string Data {
get { return data; }
}
}
}

View File

@@ -0,0 +1,34 @@
//
// DataReceivedEventHandler.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Diagnostics
{
public delegate void DataReceivedEventHandler (
object sender, DataReceivedEventArgs e);
}

View File

@@ -0,0 +1,247 @@
//
// System.Diagnostics.Debug.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
// Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation
// can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
//
// (C) 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Diagnostics;
namespace System.Diagnostics {
public static class Debug {
public static bool AutoFlush {
get {return TraceImpl.AutoFlush;}
set {TraceImpl.AutoFlush = value;}
}
public static int IndentLevel {
get {return TraceImpl.IndentLevel;}
set {TraceImpl.IndentLevel = value;}
}
public static int IndentSize {
get {return TraceImpl.IndentSize;}
set {TraceImpl.IndentSize = value;}
}
public static TraceListenerCollection Listeners {
get {return TraceImpl.Listeners;}
}
[Conditional("DEBUG")]
public static void Assert (bool condition)
{
TraceImpl.Assert (condition);
}
[Conditional("DEBUG")]
public static void Assert (bool condition, string message)
{
TraceImpl.Assert (condition, message);
}
[Conditional("DEBUG")]
public static void Assert (bool condition, string message,
string detailMessage)
{
TraceImpl.Assert (condition, message, detailMessage);
}
#if NET_4_0
[Conditional ("DEBUG")]
public static void Assert (bool condition, string message,
string detailMessageFormat, params object [] args)
{
TraceImpl.Assert (condition,
message,
string.Format (detailMessageFormat, args));
}
#endif
[Conditional("DEBUG")]
public static void Close ()
{
TraceImpl.Close ();
}
[Conditional("DEBUG")]
public static void Fail (string message)
{
TraceImpl.Fail (message);
}
[Conditional("DEBUG")]
public static void Fail (string message, string detailMessage)
{
TraceImpl.Fail (message, detailMessage);
}
[Conditional("DEBUG")]
public static void Flush ()
{
TraceImpl.Flush ();
}
[Conditional("DEBUG")]
public static void Indent ()
{
TraceImpl.Indent ();
}
[Conditional("DEBUG")]
public static void Unindent ()
{
TraceImpl.Unindent ();
}
[Conditional("DEBUG")]
public static void Write (object value)
{
TraceImpl.Write (value);
}
[Conditional("DEBUG")]
public static void Write (string message)
{
TraceImpl.Write (message);
}
[Conditional("DEBUG")]
public static void Write (object value, string category)
{
TraceImpl.Write (value, category);
}
[Conditional("DEBUG")]
public static void Write (string message, string category)
{
TraceImpl.Write (message, category);
}
[Conditional("DEBUG")]
public static void WriteIf (bool condition, object value)
{
TraceImpl.WriteIf (condition, value);
}
[Conditional("DEBUG")]
public static void WriteIf (bool condition, string message)
{
TraceImpl.WriteIf (condition, message);
}
[Conditional("DEBUG")]
public static void WriteIf (bool condition, object value,
string category)
{
TraceImpl.WriteIf (condition, value, category);
}
[Conditional("DEBUG")]
public static void WriteIf (bool condition, string message,
string category)
{
TraceImpl.WriteIf (condition, message, category);
}
[Conditional("DEBUG")]
public static void WriteLine (object value)
{
TraceImpl.WriteLine (value);
}
[Conditional("DEBUG")]
public static void WriteLine (string message)
{
TraceImpl.WriteLine (message);
}
#if NET_4_0
[Conditional("DEBUG")]
public static void WriteLine (string format, params object [] args)
{
TraceImpl.WriteLine (string.Format (format, args));
}
#endif
[Conditional("DEBUG")]
public static void WriteLine (object value, string category)
{
TraceImpl.WriteLine (value, category);
}
[Conditional("DEBUG")]
public static void WriteLine (string message, string category)
{
TraceImpl.WriteLine (message, category);
}
[Conditional("DEBUG")]
public static void WriteLineIf (bool condition, object value)
{
TraceImpl.WriteLineIf (condition, value);
}
[Conditional("DEBUG")]
public static void WriteLineIf (bool condition, string message)
{
TraceImpl.WriteLineIf (condition, message);
}
[Conditional("DEBUG")]
public static void WriteLineIf (bool condition, object value,
string category)
{
TraceImpl.WriteLineIf (condition, value, category);
}
[Conditional("DEBUG")]
public static void WriteLineIf (bool condition, string message,
string category)
{
TraceImpl.WriteLineIf (condition, message, category);
}
[Conditional("DEBUG")]
public static void Print (string message)
{
TraceImpl.WriteLine (message);
}
[Conditional("DEBUG")]
public static void Print (string format, params Object[] args)
{
TraceImpl.WriteLine (String.Format (format, args));
}
}
}

View File

@@ -0,0 +1,312 @@
//
// System.Diagnostics.DefaultTraceListener.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Comments from John R. Hicks <angryjohn69@nc.rr.com> original implementation
// can be found at: /mcs/docs/apidocs/xml/en/System.Diagnostics
//
// (C) 2002 Jonathan Pryor
// (C) 2007 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Diagnostics {
public class DefaultTraceListener : TraceListener {
private static readonly bool OnWin32;
private const string ConsoleOutTrace = "Console.Out";
private const string ConsoleErrorTrace = "Console.Error";
private static readonly string MonoTracePrefix;
private static readonly string MonoTraceFile;
static DefaultTraceListener ()
{
// Determine what platform we're on. This impacts how where we send
// messages. On Win32 platforms (OnWin32 = true), we use the
// `OutputDebugString' api.
//
// On Linux platforms, we use MONO_TRACE_LISTENER to figure things out. See the
// API documentation for more information on MONO_TRACE_LISTENER.
OnWin32 = (Path.DirectorySeparatorChar == '\\');
if (!OnWin32) {
#if TARGET_JVM
string trace = java.lang.System.getProperty("MONO_TRACE");
#else
// If we're running on Unix, we don't have OutputDebugString.
// Instead, send output to...wherever the MONO_TRACE_LISTENER environment
// variables says to.
String trace = Environment.GetEnvironmentVariable("MONO_TRACE_LISTENER");
#endif
#if MOBILE
if (trace == null)
trace = ConsoleOutTrace;
#endif
if (trace != null) {
string file = null;
string prefix = null;
if (trace.StartsWith (ConsoleOutTrace)) {
file = ConsoleOutTrace;
prefix = GetPrefix (trace, ConsoleOutTrace);
}
else if (trace.StartsWith (ConsoleErrorTrace)) {
file = ConsoleErrorTrace;
prefix = GetPrefix (trace, ConsoleErrorTrace);
}
else {
file = trace;
// We can't firgure out what the prefix would be, as ':' is a
// valid filename character. Thus, arbitrary files don't support
// prefixes.
//
// I don't consider this to be a major issue. Prefixes are useful
// with Console.Out and Console.Error to help separate trace
// output from the actual program output. Writing to an arbitrary
// file doesn't introduce issues with disambiguation.
prefix = "";
}
MonoTraceFile = file;
MonoTracePrefix = prefix;
}
}
}
/**
* Get the prefix for the specified variable.
*
* "Prefixes" are used in the MONO_TRACE_LISTENER variable, and specify text that
* should precede each message printed to the console. The prefix is
* appended to the console location with a colon (':') separating them.
* For example, if MONO_TRACE_LISTENER is "Console.Out:** my prefix", the prefix is
* "** my prefix".
*
* Everything after the colon, if the colon is present, is used as the
* prefix.
*
* @param var The current MONO_TRACE_LISTENER variable
* @param target The name of the output location, e.g. "Console.Out"
*/
private static string GetPrefix (string var, string target)
{
// actually, we permit any character to separate `target' and the prefix;
// we just skip over target the ':' would be. This means that a space or
// anything else would suffice, as long as it was only a single
// character.
if (var.Length > target.Length)
return var.Substring (target.Length + 1);
return "";
}
private string logFileName = null;
private bool assertUiEnabled = false;
public DefaultTraceListener () : base ("Default")
{
}
[MonoTODO ("AssertUiEnabled defaults to False; should follow Environment.UserInteractive.")]
public bool AssertUiEnabled {
get { return assertUiEnabled; }
set { assertUiEnabled = value; }
}
[MonoTODO]
public string LogFileName {
get {return logFileName;}
set {logFileName = value;}
}
public override void Fail (string message)
{
base.Fail (message);
}
public override void Fail (string message, string detailMessage)
{
base.Fail (message, detailMessage);
if (ProcessUI (message, detailMessage) == DialogResult.Abort)
Thread.CurrentThread.Abort ();
WriteLine (new StackTrace().ToString());
}
DialogResult ProcessUI (string message, string detailMessage)
{
if (!AssertUiEnabled)
return DialogResult.None;
object messageBoxButtonsAbortRetryIgnore;
MethodInfo msgboxShow;
try {
Assembly wfAsm = Assembly.Load (Consts.AssemblySystem_Windows_Forms);
if (wfAsm == null)
return DialogResult.None;
Type buttons = wfAsm.GetType ("System.Windows.Forms.MessageBoxButtons");
messageBoxButtonsAbortRetryIgnore = Enum.Parse (buttons, "AbortRetryIgnore");
msgboxShow = wfAsm.GetType ("System.Windows.Forms.MessageBox").GetMethod (
"Show",
new Type [] {typeof (string), typeof (string), buttons});
} catch {
return DialogResult.None;
}
if (msgboxShow == null || messageBoxButtonsAbortRetryIgnore == null)
return DialogResult.None;
string caption = String.Format ("Assertion Failed: {0} to quit, {1} to debug, {2} to continue", "Abort", "Retry", "Ignore");
string msg = String.Format ("{0}{1}{2}{1}{1}{3}", message, Environment.NewLine, detailMessage, new StackTrace ());
switch (msgboxShow.Invoke (null, new object [] {msg, caption, messageBoxButtonsAbortRetryIgnore}).ToString ()) {
case "Ignore":
return DialogResult.Ignore;
case "Abort":
return DialogResult.Abort;
default:
return DialogResult.Retry;
}
}
enum DialogResult {
None,
Retry,
Ignore,
Abort
}
#if TARGET_JVM
private void WriteDebugString (string message)
{
#else
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static void WriteWindowsDebugString (string message);
private void WriteDebugString (string message)
{
if (OnWin32)
WriteWindowsDebugString (message);
else
#endif
WriteMonoTrace (message);
}
private void WriteMonoTrace (string message)
{
switch (MonoTraceFile) {
case ConsoleOutTrace:
Console.Out.Write (message);
break;
case ConsoleErrorTrace:
Console.Error.Write (message);
break;
default:
WriteLogFile (message, MonoTraceFile);
break;
}
}
private void WritePrefix ()
{
if (!OnWin32) {
WriteMonoTrace (MonoTracePrefix);
}
}
private void WriteImpl (string message)
{
if (NeedIndent) {
WriteIndent ();
WritePrefix ();
}
WriteDebugString (message);
if (Debugger.IsLogging())
Debugger.Log (0, null, message);
WriteLogFile (message, LogFileName);
}
private void WriteLogFile (string message, string logFile)
{
string fname = logFile;
if (fname != null && fname.Length != 0) {
FileInfo info = new FileInfo (fname);
StreamWriter sw = null;
// Open the file
try {
if (info.Exists)
sw = info.AppendText ();
else
sw = info.CreateText ();
}
catch {
// We weren't able to open the file for some reason.
// We can't write to the log file; so give up.
return;
}
using (sw) {
sw.Write (message);
sw.Flush ();
}
}
}
public override void Write (string message)
{
WriteImpl (message);
}
public override void WriteLine (string message)
{
string msg = message + Environment.NewLine;
WriteImpl (msg);
NeedIndent = true;
}
}
}

View File

@@ -0,0 +1,156 @@
//
// DelimitedListTraceFilter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2007 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace System.Diagnostics
{
public class DelimitedListTraceListener : TextWriterTraceListener
{
public DelimitedListTraceListener (string fileName)
: base (fileName)
{
}
public DelimitedListTraceListener (string fileName, string name)
: base (fileName, name)
{
}
public DelimitedListTraceListener (Stream stream)
: base (stream)
{
}
public DelimitedListTraceListener (Stream stream, string name)
: base (stream, name)
{
}
public DelimitedListTraceListener (TextWriter writer)
: base (writer)
{
}
public DelimitedListTraceListener (TextWriter writer, string name)
: base (writer, name)
{
}
static readonly string [] attributes = new string [] {"delimiter"};
string delimiter = ";";
public string Delimiter {
get { return delimiter; }
set {
if (value == null)
throw new ArgumentNullException ("value");
delimiter = value;
}
}
protected internal override string [] GetSupportedAttributes ()
{
return attributes;
}
public override void TraceData (TraceEventCache eventCache,
string source, TraceEventType eventType,
int id, object data)
{
TraceCore (eventCache, source, eventType, id, null, data);
}
public override void TraceData (TraceEventCache eventCache,
string source, TraceEventType eventType,
int id, params object [] data)
{
TraceCore (eventCache, source, eventType, id, null, data);
}
public override void TraceEvent (TraceEventCache eventCache,
string source, TraceEventType eventType,
int id, string message)
{
TraceCore (eventCache, source, eventType, id, message);
}
public override void TraceEvent (TraceEventCache eventCache,
string source, TraceEventType eventType,
int id, string format, params object [] args)
{
TraceCore (eventCache, source, eventType, id, String.Format (format, args));
}
void TraceCore (TraceEventCache c, string source, TraceEventType eventType, int id, string message, params object [] data)
{
// source, eventType, id, message?, data-comma-separated
Write (String.Format ("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}{7}{0}{8}{0}{9}{0}{10}{0}{11}{12}",
delimiter,
source != null ? "\"" + source.Replace ("\"", "\"\"") + "\"": null,
eventType,
id,
message != null ? "\"" + message.Replace ("\"", "\"\"") + "\"" : null,
FormatData (data),
IsTarget (c, TraceOptions.ProcessId) ? c.ProcessId.ToString () : null,
IsTarget (c, TraceOptions.LogicalOperationStack) ? FormatArray (c.LogicalOperationStack, ", ") : null,
IsTarget (c, TraceOptions.ThreadId) ? c.ThreadId : null,
IsTarget (c, TraceOptions.DateTime) ? c.DateTime.ToString ("o") : null,
IsTarget (c, TraceOptions.Timestamp) ? c.Timestamp.ToString () : null,
IsTarget (c, TraceOptions.Callstack) ? c.Callstack : null,
Environment.NewLine));
}
bool IsTarget (TraceEventCache c, TraceOptions opt)
{
return c != null && (TraceOutputOptions & opt) != 0;
}
string FormatData (object [] data)
{
if (data == null || data.Length == 0)
return null;
StringBuilder sb = new StringBuilder ();
for (int i = 0; i < data.Length; i++) {
if (data [i] != null)
sb.Append ('"').Append (data [i].ToString ().Replace ("\"", "\"\"")).Append ('"');
if (i + 1 < data.Length)
sb.Append (',');
}
return sb.ToString ();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
//
// System.Diagnostics.EntryWrittenEventArgs.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
// (C) 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace System.Diagnostics {
public class EntryWrittenEventArgs : EventArgs {
private EventLogEntry entry;
public EntryWrittenEventArgs () : this (null)
{
}
public EntryWrittenEventArgs (EventLogEntry entry)
{
this.entry = entry;
}
public EventLogEntry Entry {
get {return entry;}
}
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Diagnostics.EntryWrittenEventHandler.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
// (C) 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace System.Diagnostics {
public delegate void EntryWrittenEventHandler(
object sender,
EntryWrittenEventArgs e);
}

View File

@@ -0,0 +1,83 @@
//
// System.Diagnostics.EventInstance
//
// Authors:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (C) 2006 Novell
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
namespace System.Diagnostics
{
public class EventInstance
{
int _categoryId;
EventLogEntryType _entryType;
long _instanceId;
public EventInstance (long instanceId, int categoryId)
: this (instanceId, categoryId, EventLogEntryType.Information)
{
}
public EventInstance (long instanceId, int categoryId, EventLogEntryType entryType)
{
InstanceId = instanceId;
CategoryId = categoryId;
EntryType = entryType;
}
public int CategoryId
{
get { return _categoryId; }
set {
if (value < 0 || value > ushort.MaxValue)
throw new ArgumentOutOfRangeException ("value");
_categoryId = value;
}
}
public EventLogEntryType EntryType
{
get { return _entryType; }
set {
if (!Enum.IsDefined (typeof (EventLogEntryType), value))
throw new InvalidEnumArgumentException("value", (int) value,
typeof(EventLogEntryType));
_entryType = value;
}
}
public long InstanceId
{
get { return _instanceId; }
set {
if (value < 0 || value > uint.MaxValue)
throw new ArgumentOutOfRangeException ("value");
_instanceId = value;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,192 @@
//
// System.Diagnostics.EventLogEntry.cs
//
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002
// (C) 2003 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace System.Diagnostics
{
[Serializable]
[ToolboxItem (false), DesignTimeVisible (false)]
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
public sealed class EventLogEntry : Component, ISerializable
{
private string category;
private short categoryNumber;
private byte[] data;
private EventLogEntryType entryType;
private int eventID;
private int index;
private string machineName;
private string message;
private string[] replacementStrings;
private string source;
private DateTime timeGenerated;
private DateTime timeWritten;
private string userName;
private long instanceId;
internal EventLogEntry (string category, short categoryNumber, int index,
int eventID, string source, string message, string userName,
string machineName, EventLogEntryType entryType,
DateTime timeGenerated, DateTime timeWritten, byte[] data,
string[] replacementStrings, long instanceId)
{
this.category = category;
this.categoryNumber = categoryNumber;
this.data = data;
this.entryType = entryType;
this.eventID = eventID;
this.index = index;
this.machineName = machineName;
this.message = message;
this.replacementStrings = replacementStrings;
this.source = source;
this.timeGenerated = timeGenerated;
this.timeWritten = timeWritten;
this.userName = userName;
this.instanceId = instanceId;
}
[MonoTODO]
private EventLogEntry (SerializationInfo info, StreamingContext context)
{
}
[MonitoringDescription ("The category of this event entry.")]
public string Category {
get { return category; }
}
[MonitoringDescription ("An ID for the category of this event entry.")]
public short CategoryNumber {
get { return categoryNumber; }
}
[MonitoringDescription ("Binary data associated with this event entry.")]
public byte[] Data {
get { return data; }
}
[MonitoringDescription ("The type of this event entry.")]
public EventLogEntryType EntryType {
get { return entryType; }
}
[Obsolete ("Use InstanceId")]
[MonitoringDescription ("An ID number for this event entry.")]
public int EventID {
get { return eventID; }
}
[MonitoringDescription ("Sequence numer of this event entry.")]
public int Index {
get { return index; }
}
[ComVisible (false)]
[MonitoringDescription ("The instance ID for this event entry.")]
public long InstanceId {
get { return instanceId; }
}
[MonitoringDescription ("The Computer on which this event entry occured.")]
public string MachineName {
get { return machineName; }
}
[Editor ("System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
[MonitoringDescription ("The message of this event entry.")]
public string Message {
get { return message; }
}
[MonitoringDescription ("Application strings for this event entry.")]
public string[] ReplacementStrings {
get { return replacementStrings; }
}
[MonitoringDescription ("The source application of this event entry.")]
public string Source {
get { return source; }
}
[MonitoringDescription ("Generation time of this event entry.")]
public DateTime TimeGenerated {
get { return timeGenerated; }
}
[MonitoringDescription ("The time at which this event entry was written to the logfile.")]
public DateTime TimeWritten {
get { return timeWritten; }
}
[MonitoringDescription ("The name of a user associated with this event entry.")]
public string UserName {
get { return userName; }
}
public bool Equals (EventLogEntry otherEntry)
{
if (otherEntry == this)
return true;
return (
(otherEntry.Category == category) &&
(otherEntry.CategoryNumber == categoryNumber) &&
(otherEntry.Data.Equals (data)) &&
(otherEntry.EntryType == entryType) &&
(otherEntry.EventID == eventID) &&
(otherEntry.Index == index) &&
(otherEntry.MachineName == machineName) &&
(otherEntry.Message == message) &&
(otherEntry.ReplacementStrings.Equals (replacementStrings)) &&
(otherEntry.Source == source) &&
(otherEntry.TimeGenerated.Equals (timeGenerated)) &&
(otherEntry.TimeWritten.Equals (timeWritten)) &&
(otherEntry.UserName == userName)
);
}
[MonoTODO ("Needs serialization support")]
void ISerializable.GetObjectData (SerializationInfo info,
StreamingContext context)
{
throw new NotImplementedException ();
}
}
}

Some files were not shown because too many files have changed in this diff Show More