-//
+//
// System.AppDomainUnloadedException.cs
//
// Author:
-// Duncan Mak (duncan@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
[Serializable]
public class AppDomainUnloadedException : SystemException
{
- // Constructors
- public AppDomainUnloadedException ()
- : base (Locale.GetText ("Can't access an unloaded application domain."))
- {
- }
+ // Constructors
+ public AppDomainUnloadedException ()
+ : base (Locale.GetText ("Can't access an unloaded application domain."))
+ {
+ }
+
+ public AppDomainUnloadedException (string message)
+ : base (message)
+ {
+ }
- public AppDomainUnloadedException (string message)
- : base (message)
- {
- }
-
- protected AppDomainUnloadedException (SerializationInfo info,
- StreamingContext context)
- : base (info, context)
- {
- }
+ public AppDomainUnloadedException (string message, Exception innerException)
+ :base (message, innerException)
+ {
+ }
- public AppDomainUnloadedException (string message, Exception innerException)
- :base (message, innerException)
- {
- }
-
+ protected AppDomainUnloadedException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
+ {
+ }
}
}
//
using System.Reflection;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
{
-
[Serializable]
public class ApplicationException : Exception
{
{
}
- public ApplicationException (string message, Exception inner)
- : base (message, inner)
+ public ApplicationException (string message, Exception innerException)
+ : base (message, innerException)
{
}
{
IntPtr sig;
IntPtr args;
- int next_arg;
- int num_args;
+ int next_arg;
+ int num_args;
[MethodImpl (MethodImplOptions.InternalCall)]
extern void Setup (IntPtr argsp, IntPtr start);
public override bool Equals (object o)
{
- throw new NotSupportedException("This operation is not supported for this type");
+ throw new NotSupportedException (Locale.GetText ("ArgIterator does not support Equals."));
}
public override int GetHashCode ()
public TypedReference GetNextArg ()
{
if (num_args == next_arg)
- throw new InvalidOperationException ("invalid iterator position");
+ throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg ();
}
public TypedReference GetNextArg (RuntimeTypeHandle rth)
{
if (num_args == next_arg)
- throw new InvalidOperationException ("invalid iterator position");
+ throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg (rth.Value);
}
public RuntimeTypeHandle GetNextArgType ()
{
if (num_args == next_arg)
- throw new InvalidOperationException ("invalid iterator position");
+ throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return new RuntimeTypeHandle (IntGetNextArgType ());
}
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Runtime.Serialization;
-using System.Globalization;
-namespace System {
+using System.Runtime.Serialization;
+namespace System
+{
[Serializable]
- public class ArgumentException : SystemException {
+ public class ArgumentException : SystemException
+ {
private string param_name;
// Constructors
{
}
- public ArgumentException (string message, Exception inner)
- : base (message, inner)
+ public ArgumentException (string message, Exception innerException)
+ : base (message, innerException)
{
}
- public ArgumentException (string message, string param_name)
+ public ArgumentException (string message, string paramName)
: base (message)
{
- this.param_name = param_name;
+ this.param_name = paramName;
}
- public ArgumentException (string message, string param_name, Exception inner)
- : base (message, inner)
+ public ArgumentException (string message, string paramName, Exception innerException)
+ : base (message, innerException)
{
- this.param_name = param_name;
+ this.param_name = paramName;
}
- protected ArgumentException (SerializationInfo info, StreamingContext sc)
- : base (info, sc)
+ protected ArgumentException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
{
param_name = info.GetString ("ParamName");
}
- // Properties
+ // Properties
public virtual string ParamName {
get {
return param_name;
if (param_name == null)
return base_message;
else
- return base_message + "\nParameter name: " + param_name;
+ return base_message + Environment.NewLine + Locale.GetText ("Parameter name: ") + param_name;
}
}
-
+
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
//
using System.Runtime.Serialization;
-using System.Globalization;
-
-namespace System {
+namespace System
+{
[Serializable]
- public class ArgumentNullException : ArgumentException {
+ public class ArgumentNullException : ArgumentException
+ {
// Constructors
public ArgumentNullException ()
- : base (Locale.GetText ("Argument cannot be null"))
+ : base (Locale.GetText ("Argument cannot be null."))
{
}
- public ArgumentNullException (string param_name)
- : base (Locale.GetText ("Argument cannot be null"), param_name)
+ public ArgumentNullException (string paramName)
+ : base (Locale.GetText ("Argument cannot be null."), paramName)
{
}
- public ArgumentNullException (string param_name, string message)
- : base (message, param_name)
+ public ArgumentNullException (string paramName, string message)
+ : base (message, paramName)
{
}
- protected ArgumentNullException (SerializationInfo info, StreamingContext sc)
- : base (info, sc)
+ protected ArgumentNullException (SerializationInfo info, StreamingContext context)
+ : base (info, context)
{
}
}
//
// System.ArgumentOutOfRangeException.cs
//
-// Author:
+// Authors:
// Joe Shaw (joe@ximian.com)
// Duncan Mak (duncan@ximian.com)
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Globalization;
using System.Runtime.Serialization;
-namespace System {
-
+namespace System
+{
[Serializable]
- public class ArgumentOutOfRangeException : ArgumentException {
+ public class ArgumentOutOfRangeException : ArgumentException
+ {
private object actual_value;
// Constructors
public ArgumentOutOfRangeException ()
- : base (Locale.GetText ("Argument is out of range"))
+ : base (Locale.GetText ("Argument is out of range."))
{
}
- public ArgumentOutOfRangeException (string param_name)
- : base (Locale.GetText ("Argument is out of range"), param_name)
+ public ArgumentOutOfRangeException (string paramName)
+ : base (Locale.GetText ("Argument is out of range."), paramName)
{
}
- public ArgumentOutOfRangeException (string param_name, string message)
- : base (message, param_name)
+ public ArgumentOutOfRangeException (string paramName, string message)
+ : base (message, paramName)
{
}
- public ArgumentOutOfRangeException (string param_name, object actual_value, string message)
- : base (message, param_name)
+ public ArgumentOutOfRangeException (string paramName, object actualValue, string message)
+ : base (message, paramName)
{
- this.actual_value = actual_value;
+ this.actual_value = actualValue;
}
protected ArgumentOutOfRangeException (SerializationInfo info, StreamingContext context)
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Globalization;
using System.Runtime.Serialization;
-namespace System {
+namespace System
+{
[Serializable]
- public class ArithmeticException : SystemException {
+ public class ArithmeticException : SystemException
+ {
// Constructors
public ArithmeticException ()
- : base (Locale.GetText ("The arithmetic operation is not allowed"))
+ : base (Locale.GetText ("The arithmetic operation is not allowed."))
{
}
{
}
- public ArithmeticException (string message, Exception inner)
- : base (message, inner)
+ public ArithmeticException (string message, Exception innerException)
+ : base (message, innerException)
{
}
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Globalization;
+
using System.Runtime.Serialization;
-namespace System {
+namespace System
+{
[Serializable]
- public class ArrayTypeMismatchException : SystemException {
+ public class ArrayTypeMismatchException : SystemException
+ {
// Constructors
public ArrayTypeMismatchException ()
- : base (Locale.GetText ("Source array type cannot be assigned to destination array type"))
+ : base (Locale.GetText ("Source array type cannot be assigned to destination array type."))
{
}
{
}
- public ArrayTypeMismatchException (string message, Exception inner)
- : base (message, inner)
+ public ArrayTypeMismatchException (string message, Exception innerException)
+ : base (message, innerException)
{
}
: base (info, context)
{
}
-
-
}
}
//
-// System.AssemblyLoadEventArgs.cs
+// System.AssemblyLoadEventArgs.cs
//
// Author:
// Chris Hynes (chrish@assistedsolutions.com)
// (C) 2001 Chris Hynes
//
-using System;
using System.Reflection;
namespace System
{
private Assembly m_loadedAssembly;
- public AssemblyLoadEventArgs(Assembly loadedAssembly)
+ public AssemblyLoadEventArgs (Assembly loadedAssembly)
{
this.m_loadedAssembly = loadedAssembly;
}
- public Assembly LoadedAssembly
- {
- get
- {
+ public Assembly LoadedAssembly {
+ get {
return m_loadedAssembly;
}
}
}
}
-
-
+//
// System.AssemblyLoadEventHandler.cs
//
// Paolo Molaro
//
// (C) 2002 Ximian, Inc.
+//
namespace System
{
//
-// System/AsyncCallback.cs
+// System.AsyncCallback.cs
//
// Author:
// Paolo Molaro (lupus@ximian.com)
// (C) Ximian, Inc. http://www.ximian.com
//
-namespace System {
+namespace System
+{
public delegate void AsyncCallback (IAsyncResult ar);
}
-
-// AttributeTargets.cs
+//
+// System.AttributeTargets.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
-
-namespace System {
-
-
- /// <summary>
- /// </summary>
+namespace System
+{
[Flags]
- public enum AttributeTargets {
-
- /// <summary>
- /// </summary>
+ public enum AttributeTargets
+ {
Assembly = 0x00000001,
-
- /// <summary>
- /// </summary>
Module = 0x00000002,
-
- /// <summary>
- /// </summary>
Class = 0x00000004,
-
- /// <summary>
- /// </summary>
Struct = 0x00000008,
-
- /// <summary>
- /// </summary>
Enum = 0x00000010,
-
- /// <summary>
- /// </summary>
Constructor = 0x00000020,
-
- /// <summary>
- /// </summary>
Method = 0x00000040,
-
- /// <summary>
- /// </summary>
Property = 0x00000080,
-
- /// <summary>
- /// </summary>
Field = 0x00000100,
-
- /// <summary>
- /// </summary>
Event = 0x00000200,
-
- /// <summary>
- /// </summary>
Interface = 0x00000400,
-
- /// <summary>
- /// </summary>
Parameter = 0x00000800,
-
- /// <summary>
- /// </summary>
Delegate = 0x00001000,
-
- /// <summary>
- /// </summary>
ReturnValue = 0x00002000,
+ All = Assembly | Module | Class | Struct | Enum | Constructor |
+ Method | Property | Field | Event | Interface | Parameter | Delegate | ReturnValue
+ }
+}
- /// <summary>
- /// </summary>
- All = Assembly | Module | Class | Struct | Enum | Constructor | Method | Property | Field | Event | Interface | Parameter | Delegate | ReturnValue,
- } // AttributeTargets
-
-} // System
-//\r
-// System.AttributeUsage.cs\r
-//\r
-// Author:\r
-// Miguel de Icaza (miguel@ximian.com)\r
-//\r
-// (C) Ximian, Inc. http://www.ximian.com\r
-//\r
-\r
-namespace System {\r
-\r
- [AttributeUsage(AttributeTargets.All)]\r
- [Serializable]\r
- public sealed class AttributeUsageAttribute : Attribute {\r
- AttributeTargets valid_on;\r
- bool allow_multiple, inherited;\r
- \r
- public AttributeUsageAttribute (AttributeTargets validOn)\r
- {\r
- valid_on = validOn;\r
- }\r
-\r
- public bool AllowMultiple {\r
- get {\r
- return allow_multiple;\r
- }\r
-\r
- set {\r
- allow_multiple = value;\r
- }\r
- }\r
-\r
- public bool Inherited {\r
- get {\r
- return inherited;\r
- }\r
-\r
- set {\r
- inherited = value;\r
- }\r
- }\r
-\r
- public AttributeTargets ValidOn {\r
- get {\r
- return valid_on;\r
- }\r
- }\r
- }\r
-}\r
-\r
+//
+// System.AttributeUsageAttribute.cs
+//
+// Author:
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+namespace System
+{
+ [Serializable]
+ [AttributeUsage(AttributeTargets.All)]
+ public sealed class AttributeUsageAttribute : Attribute
+ {
+ AttributeTargets valid_on;
+ bool allow_multiple, inherited;
+
+ public AttributeUsageAttribute (AttributeTargets validOn)
+ {
+ valid_on = validOn;
+ }
+
+ public bool AllowMultiple {
+ get {
+ return allow_multiple;
+ }
+ set {
+ allow_multiple = value;
+ }
+ }
+
+ public bool Inherited {
+ get {
+ return inherited;
+ }
+ set {
+ inherited = value;
+ }
+ }
+
+ public AttributeTargets ValidOn {
+ get {
+ return valid_on;
+ }
+ }
+ }
+}
+
+
-// System.BadImageFormatException
//
-// Sean MacIsaac (macisaac@ximian.com)
-// Duncan Mak (duncan@ximian.com)
+// System.BadImageFormatException.cs
+//
+// Authors:
+// Sean MacIsaac (macisaac@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// (C) 2001 Ximian, Inc.
+//
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
{
[Serializable]
+ [MonoTODO ("fix wrong impl.")]
public class BadImageFormatException : SystemException
{
// Fields
fusionLog = info.GetString ("BadImageFormat_FusionLog");
}
- public BadImageFormatException (string message, Exception inner)
- : base (message, inner)
+ public BadImageFormatException (string message, Exception innerException)
+ : base (message, innerException)
{
msg = message;
- this.inner = inner;
+ this.inner = innerException;
}
public BadImageFormatException (string message, string fileName)
this.fileName = fileName;
}
- public BadImageFormatException (string message, string fileName, Exception inner)
- : base (message, inner)
+ public BadImageFormatException (string message, string fileName, Exception innerException)
+ : base (message, innerException)
{
msg = message;
- this.inner = inner;
+ this.inner = innerException;
this.fileName = fileName;
}
// (C) Ximian, Inc. http://www.ximian.com
//
-namespace System {
-
+namespace System
+{
/// <summary>
/// Used to indicate if an element of a program is CLS compliant.
/// </summary>
- ///
- /// <remarks>
- /// </remarks>
- [AttributeUsage(AttributeTargets.All)]
+ [AttributeUsage (AttributeTargets.All)]
[Serializable]
- public sealed class CLSCompliantAttribute : Attribute {
-
+ public sealed class CLSCompliantAttribute : Attribute
+ {
bool is_compliant;
- public CLSCompliantAttribute (bool is_compliant)
+ public CLSCompliantAttribute (bool isCompliant)
{
- this.is_compliant = is_compliant;
+ this.is_compliant = isCompliant;
}
public bool IsCompliant {
//
-// System.CannotUnloadAppDomainException
+// System.CannotUnloadAppDomainException.cs
//
// Author:
-// Duncan Mak (duncan@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
// Constructors
public CannotUnloadAppDomainException ()
: base (Locale.GetText ("Attempt to unload application domain failed."))
- {
- }
-
+ {
+ }
+
public CannotUnloadAppDomainException (string message)
: base (message)
- {
- }
-
- protected CannotUnloadAppDomainException (SerializationInfo info,
- StreamingContext context)
+ {
+ }
+
+ protected CannotUnloadAppDomainException (SerializationInfo info, StreamingContext context)
: base (info, context)
- {
- }
-
+ {
+ }
+
public CannotUnloadAppDomainException (string message, Exception innerException)
:base (message, innerException)
- {
- }
+ {
+ }
}
}
+2004-03-13 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+ * Enum.cs
+ * EntryPointNotFoundException.cs
+ * DuplicateWaitObjectException.cs
+ * DoubleFormatter.cs
+ * DllNotFoundException.cs
+ * DivideByZeroException.cs
+ * DelegateSerializationHolder.cs
+ * Delegate.cs
+ * DBNull.cs
+ * ContextStaticAttribute.cs
+ * ContextMarshalException.cs
+ * ContextBoundObject.cs
+ * CLSCompliantAttribute.cs
+ * CharEnumerator.cs
+ * CannotUnloadAppDomainException.cs
+ * BadImageFormatException.cs
+ * AttributeUsageAttribute.cs
+ * AttributeTargets.cs
+ * AsyncCallback.cs
+ * AssemblyLoadEventHandler.cs
+ * AssemblyLoadEventArgs.cs
+ * ArrayTypeMismatchException.cs
+ * ArithmeticException.cs
+ * ArgumentOutOfRangeException.cs
+ * ArgumentNullException.cs
+ * ArgumentException.cs
+ * ArgIterator.cs
+ * ApplicationException.cs
+ * AppDomainUnloadedException.cs
+ * AppDomain.cs: Mono styled, fixed exceptions/ locales
+ removed excess usings
+
2004-03-10 Sebastien Pouliot <sebastien@ximian.com>
* Convert.cs: FromBase64 now ignore some characters (tab, LF, CR and
//
// System.CharEnumerator.cs
//
-// Author: Duncan Mak (duncan@ximian.com)
+// Author:
+// Duncan Mak (duncan@ximian.com)
//
// (C) Ximian, Inc.
//
// Constructor
internal CharEnumerator (string s)
{
- str = s;
- index = -1;
- length = s.Length;
+ str = s;
+ index = -1;
+ length = s.Length;
}
-
- // Property
- public char Current
- {
+
+ // Properties
+ public char Current {
get {
if (index == -1 || index >= length)
- throw new InvalidOperationException
- ("The position is not valid.");
-
+ throw new InvalidOperationException (Locale.GetText ("The position is not valid."));
return str [index];
}
}
-
- object IEnumerator.Current
- {
+
+ object IEnumerator.Current {
get {
return Current;
}
}
-
+
// Methods
public object Clone ()
{
x.index = index;
return x;
}
-
+
public bool MoveNext ()
{
// Representation invariant holds: -1 <= index <= length
else
return true;
}
-
+
public void Reset ()
{
index = -1;
//
// (C) Ximian, Inc. http://www.ximian.com
//
-// TODO: Mucho left to implement.
-//
-
-namespace System {
- /// <summary>
- /// Base class for all the context-bound classes
- /// </summary>
+namespace System
+{
[Serializable]
- public abstract class ContextBoundObject : MarshalByRefObject {
-
+ public abstract class ContextBoundObject : MarshalByRefObject
+ {
protected ContextBoundObject ()
{
}
// System.ContextMarshalException.cs
//
// Author:
-// Duncan Mak (duncan@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
// Constructors
public ContextMarshalException ()
: base (Locale.GetText ("Attempt to marshal and object across a context failed."))
- {
- }
-
+ {
+ }
+
public ContextMarshalException (string message)
: base (message)
- {
- }
+ {
+ }
- protected ContextMarshalException (SerializationInfo info,
- StreamingContext context)
+ protected ContextMarshalException (SerializationInfo info, StreamingContext context)
: base (info, context)
- {
- }
+ {
+ }
public ContextMarshalException (string message, Exception innerException)
:base (message, innerException)
- {
- }
-
+ {
+ }
}
}
// (C) Ximian, Inc. http://www.ximian.com
//
-namespace System {
-
+namespace System
+{
/// <summary>
/// The ContextStatic attribute is used to flag fields as being unique
/// </summary>
- ///
- /// <remarks>
- ///
- /// </remarks>
[AttributeUsage (AttributeTargets.Field)]
[Serializable]
- public class ContextStaticAttribute : Attribute {
-
- public ContextStaticAttribute () : base ()
- {
- }
-
+ public class ContextStaticAttribute : Attribute
+ {
+ public ContextStaticAttribute ()
+ : base ()
+ {
+ }
}
}
//
-// DBNull.cs
+// System.DBNull.cs
//
// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Ben Maurer (bmaurer@users.sourceforge.net)
+// Duncan Mak (duncan@ximian.com)
+// Ben Maurer (bmaurer@users.sourceforge.net)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// (C) 2003 Ben Maurer
public static readonly DBNull Value = new DBNull ();
// Private constructor
- private DBNull () {}
+ private DBNull ()
+ {
+ }
+
+ private DBNull (SerializationInfo info, StreamingContext context)
+ {
+ throw new NotSupportedException ();
+ }
// Methods
public void GetObjectData (SerializationInfo info, StreamingContext context)
object IConvertible.ToType (Type type, IFormatProvider provider)
{
- if (type == typeof (string)) return String.Empty;
+ if (type == typeof (string))
+ return String.Empty;
throw new InvalidCastException ();
}
//
// System.Delegate.cs
//
-// Author:
+// Authors:
// Miguel de Icaza (miguel@ximian.com)
// Daniel Stodden (stodden@in.tum.de)
// Dietmar Maurer (dietmar@ximian.com)
// (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-
-namespace System {
-
+namespace System
+{
#if NET_1_1
[ClassInterface (ClassInterfaceType.AutoDual)]
#endif
[MonoTODO]
- public abstract class Delegate : ICloneable, ISerializable {
+ public abstract class Delegate : ICloneable, ISerializable
+ {
protected Type target_type;
protected object m_target;
protected string method_name;
protected Delegate (object target, string method)
{
if (target == null)
- throw new ArgumentNullException (Locale.GetText ("Target object is null"));
+ throw new ArgumentNullException ("target");
if (method == null)
- throw new ArgumentNullException (Locale.GetText ("method name is null"));
+ throw new ArgumentNullException ("method");
this.target_type = null;
this.method_ptr = IntPtr.Zero;
this.method_name = method;
}
- protected Delegate (Type target_type, string method)
+ protected Delegate (Type target, string method)
{
- if (target_type == null)
- throw new ArgumentNullException (Locale.GetText ("Target type is null"));
+ if (target == null)
+ throw new ArgumentNullException ("target");
if (method == null)
- throw new ArgumentNullException (Locale.GetText ("method string is null"));
+ throw new ArgumentNullException ("method");
- this.target_type = target_type;
+ this.target_type = target;
this.method_ptr = IntPtr.Zero;
this.m_target = null;
this.method_name = method;
// Methods
//
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern Delegate CreateDelegate_internal (Type type, object target, MethodInfo info);
- public static Delegate CreateDelegate (Type type, MethodInfo info)
+ public static Delegate CreateDelegate (Type type, MethodInfo method)
{
if (type == null)
- throw new ArgumentNullException (Locale.GetText ("Type is null"));
+ throw new ArgumentNullException ("type");
- if (info == null)
- throw new ArgumentNullException (Locale.GetText ("MethodInfo is null"));
+ if (method == null)
+ throw new ArgumentNullException ("method");
if (!type.IsSubclassOf (typeof (MulticastDelegate)))
throw new ArgumentException ("type");
- if (!info.IsStatic)
- throw new ArgumentException ("The method should be static.", "info");
+ if (!method.IsStatic)
+ throw new ArgumentException ("The method should be static.", "method");
ParameterInfo[] delargs = type.GetMethod ("Invoke").GetParameters ();
- ParameterInfo[] args = info.GetParameters ();
+ ParameterInfo[] args = method.GetParameters ();
if (args.Length != delargs.Length)
- throw new ArgumentException ("info");
+ throw new ArgumentException ("method");
int length = delargs.Length;
for (int i = 0; i < length; i++)
if (delargs [i].ParameterType != args [i].ParameterType)
- throw new ArgumentException ("info");
+ throw new ArgumentException ("method");
- return CreateDelegate_internal (type, null, info);
+ return CreateDelegate_internal (type, null, method);
}
public static Delegate CreateDelegate (Type type, object target, string method)
public static Delegate CreateDelegate (Type type, Type target, string method)
{
if (type == null)
- throw new ArgumentNullException (Locale.GetText ("Type is null"));
+ throw new ArgumentNullException ("type");
if (target == null)
- throw new ArgumentNullException (Locale.GetText ("Target type is null"));
+ throw new ArgumentNullException ("target");
if (method == null)
- throw new ArgumentNullException (Locale.GetText ("method string is null"));
+ throw new ArgumentNullException ("method");
if (!type.IsSubclassOf (typeof (MulticastDelegate)))
- throw new ArgumentException ("type is not subclass of MulticastDelegate");
+ throw new ArgumentException ("type is not subclass of MulticastDelegate.");
ParameterInfo[] delargs = type.GetMethod ("Invoke").GetParameters ();
Type[] delargtypes = new Type [delargs.Length];
MethodInfo info = target.GetMethod (method, flags, null, delargtypes, new ParameterModifier [0]);
if (info == null)
- throw new ArgumentException ("Couldn't bind to method");
+ throw new ArgumentException ("Couldn't bind to method.");
return CreateDelegate_internal (type, null, info);
}
- public static Delegate CreateDelegate (Type type, object target, string method, bool ignorecase)
+ public static Delegate CreateDelegate (Type type, object target, string method, bool ignoreCase)
{
if (type == null)
- throw new ArgumentNullException (Locale.GetText ("Type is null"));
+ throw new ArgumentNullException ("type");
if (target == null)
- throw new ArgumentNullException (Locale.GetText ("Target object is null"));
+ throw new ArgumentNullException ("target");
if (method == null)
- throw new ArgumentNullException (Locale.GetText ("method string is null"));
+ throw new ArgumentNullException ("method");
if (!type.IsSubclassOf (typeof (MulticastDelegate)))
throw new ArgumentException ("type");
*/
BindingFlags flags = BindingFlags.ExactBinding | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
- if (ignorecase)
+ if (ignoreCase)
flags |= BindingFlags.IgnoreCase;
MethodInfo info = target.GetType ().GetMethod (method, flags, null, delargtypes, new ParameterModifier [0]);
if (info == null)
- throw new ArgumentException ("Couldn't bind to method '" + method + "'");
+ throw new ArgumentException ("Couldn't bind to method '" + method + "'.");
return CreateDelegate_internal (type, target, info);
}
internal virtual object DynamicInvokeImpl (object[] args)
{
- if (Method == null){
+ if (Method == null) {
Type[] mtypes = new Type [args.Length];
- for (int i = 0; i < args.Length; ++i){
+ for (int i = 0; i < args.Length; ++i) {
mtypes [i] = args [i].GetType ();
}
method_info = m_target.GetType ().GetMethod (method_name, mtypes);
return MemberwiseClone ();
}
- public override bool Equals (object o)
+ public override bool Equals (object obj)
{
- if (o == null)
+ if (obj == null)
return false;
-
- Delegate d = (Delegate) o;
+
+ Delegate d = (Delegate) obj;
// Do not compare method_ptr, since it can point to a trampoline
- if ((d.target_type == target_type) &&
- (d.m_target == m_target) &&
- (d.method_name == method_name) &&
- (d.method_info == method_info))
+ if ((d.target_type == target_type) && (d.m_target == m_target) &&
+ (d.method_name == method_name) && (d.method_info == method_info))
return true;
return false;
/// </symmary>
public static Delegate Combine (Delegate a, Delegate b)
{
- if (a == null){
+ if (a == null) {
if (b == null)
return null;
return b;
return a;
if (a.GetType () != b.GetType ())
- throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types"));
+ throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types."));
return a.CombineImpl (b);
}
/// Returns a new MulticastDelegate holding the
/// concatenated invocation lists of an Array of MulticastDelegates
/// </symmary>
- public static Delegate Combine( Delegate[] delegates )
+ public static Delegate Combine (Delegate[] delegates)
{
Delegate retval = null;
return retval;
}
-
protected virtual Delegate CombineImpl (Delegate d)
{
throw new MulticastNotSupportedException ("");
}
-
-
+
public static Delegate Remove (Delegate source, Delegate value)
{
if (source == null)
return null;
-
+
return source.RemoveImpl (value);
}
{
if (this.Equals (d))
return null;
-
+
return this;
}
#if NET_1_1
-// DelegateSerializationHolder.cs
+//
+// System.DelegateSerializationHolder.cs
//
// Author:
-// Lluis Sanchez Gual (lsg@ctv.es)
+// Lluis Sanchez Gual (lsg@ctv.es)
//
// (C) 2003 Lluis Sanchez Gual
+//
-using System;\r
-using System.Reflection;\r
+using System.Reflection;
using System.Runtime.Serialization;
-\r
-namespace System\r
-{\r
- [Serializable]\r
- public class DelegateSerializationHolder: ISerializable, IObjectReference\r
- {\r
- Delegate _delegate; // The deserialized delegate\r
-\r
- [Serializable]\r
- class DelegateEntry\r
- {\r
- // A DelegateEntry holds information about a delegate that is part\r
- // of an invocation list of a multicast delegate.\r
-\r
- public DelegateEntry (Delegate del, string targetLabel)\r
- {\r
- type = del.GetType().FullName;\r
- assembly = del.GetType().Assembly.FullName;\r
- target = targetLabel;\r
- targetTypeAssembly = del.Method.DeclaringType.Assembly.FullName;\r
- targetTypeName = del.Method.DeclaringType.FullName;\r
- methodName = del.Method.Name;\r
- }\r
-\r
- public Delegate DeserializeDelegate(SerializationInfo info)\r
- {\r
- object realTarget = null;\r
- if (target != null)\r
- realTarget = info.GetValue (target.ToString(), typeof(object));\r
-\r
- Assembly dasm = Assembly.Load (assembly);\r
- Type dt = dasm.GetType (type);\r
-\r
- Delegate del;\r
- if (realTarget != null)\r
- del = Delegate.CreateDelegate (dt, realTarget, methodName);\r
- else\r
- {\r
- Assembly tasm = Assembly.Load (targetTypeAssembly);\r
- Type tt = tasm.GetType (targetTypeName);\r
- del = Delegate.CreateDelegate (dt, tt, methodName);\r
- }\r
-\r
- if (!del.Method.IsPublic)\r
- throw new SerializationException ("Serialization will not deserialize delegates to non-public methods.");\r
-\r
- return del;\r
- }\r
-\r
- string type;\r
- string assembly;\r
- public object target;\r
- string targetTypeAssembly;\r
- string targetTypeName;\r
- string methodName;\r
- public DelegateEntry delegateEntry; // next delegate in the invocation list\r
- }\r
-\r
- DelegateSerializationHolder(SerializationInfo info, StreamingContext ctx)\r
- {\r
- DelegateEntry entryChain = (DelegateEntry)info.GetValue ("Delegate", typeof(DelegateEntry));\r
-\r
- // Count the number of delegates to combine\r
-\r
- int count = 0;\r
- DelegateEntry entry = entryChain;\r
- while (entry != null)\r
- {\r
- entry = entry.delegateEntry;\r
- count++;\r
- }\r
-\r
- // Deserializes and combines the delegates\r
-\r
- if (count == 1) \r
- _delegate = entryChain.DeserializeDelegate (info);\r
- else\r
- {\r
- Delegate[] delegates = new Delegate[count];\r
- entry = entryChain;\r
- for (int n=0; n<count; n++)\r
- {\r
- delegates[n] = entry.DeserializeDelegate (info);\r
- entry = entry.delegateEntry;\r
- }\r
-\r
- _delegate = Delegate.Combine (delegates);\r
- }\r
- }\r
-\r
- public static void GetDelegateData(Delegate instance, SerializationInfo info, StreamingContext ctx)\r
- {\r
- // Fills a SerializationInfo object with the information of the delegate.\r
-\r
- Delegate[] delegates = instance.GetInvocationList();\r
- DelegateEntry lastEntry = null;\r
- for (int n=0; n<delegates.Length; n++)\r
- {\r
- Delegate del = delegates[n];\r
- string targetLabel = (del.Target != null) ? ("target" + n) : null;\r
- DelegateEntry entry = new DelegateEntry(del, targetLabel);\r
-\r
- if (lastEntry == null)\r
- info.AddValue ("Delegate", entry);\r
- else\r
- lastEntry.delegateEntry = entry;\r
-\r
- lastEntry = entry;\r
- if (del.Target != null)\r
- info.AddValue (targetLabel, del.Target);\r
- }\r
+
+namespace System
+{
+ [Serializable]
+ public class DelegateSerializationHolder: ISerializable, IObjectReference
+ {
+ Delegate _delegate; // The deserialized delegate
+
+ [Serializable]
+ class DelegateEntry
+ {
+ string type;
+ string assembly;
+ public object target;
+ string targetTypeAssembly;
+ string targetTypeName;
+ string methodName;
+ public DelegateEntry delegateEntry; // next delegate in the invocation list
+
+ // A DelegateEntry holds information about a delegate that is part
+ // of an invocation list of a multicast delegate.
+ public DelegateEntry (Delegate del, string targetLabel)
+ {
+ type = del.GetType().FullName;
+ assembly = del.GetType().Assembly.FullName;
+ target = targetLabel;
+ targetTypeAssembly = del.Method.DeclaringType.Assembly.FullName;
+ targetTypeName = del.Method.DeclaringType.FullName;
+ methodName = del.Method.Name;
+ }
+
+ public Delegate DeserializeDelegate (SerializationInfo info)
+ {
+ object realTarget = null;
+ if (target != null)
+ realTarget = info.GetValue (target.ToString(), typeof(object));
+
+ Assembly dasm = Assembly.Load (assembly);
+ Type dt = dasm.GetType (type);
+ Delegate del;
+ if (realTarget != null)
+ del = Delegate.CreateDelegate (dt, realTarget, methodName);
+ else {
+ Assembly tasm = Assembly.Load (targetTypeAssembly);
+ Type tt = tasm.GetType (targetTypeName);
+ del = Delegate.CreateDelegate (dt, tt, methodName);
+ }
+
+ if (!del.Method.IsPublic)
+ throw new SerializationException (Locale.GetText (
+ "Serialization will not deserialize delegates to non-public methods."));
+
+ return del;
+ }
+ }
+
+ DelegateSerializationHolder(SerializationInfo info, StreamingContext ctx)
+ {
+ DelegateEntry entryChain = (DelegateEntry)info.GetValue ("Delegate", typeof(DelegateEntry));
+
+ // Count the number of delegates to combine
+ int count = 0;
+ DelegateEntry entry = entryChain;
+ while (entry != null) {
+ entry = entry.delegateEntry;
+ count++;
+ }
+
+ // Deserializes and combines the delegates
+ if (count == 1)
+ _delegate = entryChain.DeserializeDelegate (info);
+ else
+ {
+ Delegate[] delegates = new Delegate[count];
+ entry = entryChain;
+ for (int n=0; n<count; n++)
+ {
+ delegates[n] = entry.DeserializeDelegate (info);
+ entry = entry.delegateEntry;
+ }
+ _delegate = Delegate.Combine (delegates);
+ }
+ }
+
+ public static void GetDelegateData (Delegate instance, SerializationInfo info, StreamingContext ctx)
+ {
+ // Fills a SerializationInfo object with the information of the delegate.
+
+ Delegate[] delegates = instance.GetInvocationList ();
+ DelegateEntry lastEntry = null;
+ for (int n=0; n<delegates.Length; n++) {
+ Delegate del = delegates[n];
+ string targetLabel = (del.Target != null) ? ("target" + n) : null;
+ DelegateEntry entry = new DelegateEntry (del, targetLabel);
+
+ if (lastEntry == null)
+ info.AddValue ("Delegate", entry);
+ else
+ lastEntry.delegateEntry = entry;
+
+ lastEntry = entry;
+ if (del.Target != null)
+ info.AddValue (targetLabel, del.Target);
+ }
info.SetType (typeof (DelegateSerializationHolder));
- }\r
-\r
- public void GetObjectData(SerializationInfo info, StreamingContext context)\r
- {\r
- // Not needed.\r
- throw new NotSupportedException();\r
- }\r
-\r
- public object GetRealObject(StreamingContext context)\r
- {\r
- return _delegate;\r
- }\r
- }\r
-}\r
+ }
+
+ public void GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ // Not needed.
+ throw new NotSupportedException ();
+ }
+
+ public object GetRealObject (StreamingContext context)
+ {
+ return _delegate;
+ }
+ }
+}
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Globalization;
using System.Runtime.Serialization;
-namespace System {
-
+namespace System
+{
[Serializable]
- public class DivideByZeroException : ArithmeticException {
+ public class DivideByZeroException : ArithmeticException
+ {
// Constructors
public DivideByZeroException ()
: base (Locale.GetText ("Division by zero"))
{
}
- public DivideByZeroException (string message, Exception inner)
- : base (message, inner)
+ public DivideByZeroException (string message, Exception innerException)
+ : base (message, innerException)
{
}
-//
+//
// System.DllNotFoundException.cs
//
// Author:
-// Duncan Mak (duncan@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
// Constructors
public DllNotFoundException ()
: base (Locale.GetText ("DLL not found."))
- {
- }
-
+ {
+ }
+
public DllNotFoundException (string message)
: base (message)
- {
- }
-
- protected DllNotFoundException (SerializationInfo info,
- StreamingContext context)
+ {
+ }
+
+ protected DllNotFoundException (SerializationInfo info, StreamingContext context)
: base (info, context)
- {
- }
-
+ {
+ }
+
public DllNotFoundException (string message, Exception innerException)
:base (message, innerException)
- {
- }
-
+ {
+ }
}
}
// Copyright (C) 2003 Pedro MartÃnez Juliá <yoros@wanadoo.es>
//
-using System;
using System.Text;
using System.Collections;
using System.Globalization;
-
-namespace System {
-
- internal class DoubleFormatter {
-
+namespace System
+{
+ internal class DoubleFormatter
+ {
private static FloatingPointFormatter fpf;
-
+
const double p = 100000000000000.0d;
const double p10 = 1000000000000000.0;
const int dec_len = 14;
const int dec_len_min = -30;
-
const double p2 = 10000000000000000.0d;
const double p102 = 100000000000000000.0;
const int dec_len2 = 16;
const int dec_len_min2 = -34;
- public static string NumberToString (string format,
- NumberFormatInfo nfi, double value) {
+ internal static string NumberToString (string format, NumberFormatInfo nfi, double value)
+ {
if (fpf == null) {
- fpf = new FloatingPointFormatter (p, p10, dec_len,
- dec_len_min, p2, p102, dec_len2, dec_len_min2);
+ fpf = new FloatingPointFormatter (p, p10, dec_len, dec_len_min, p2, p102, dec_len2, dec_len_min2);
}
return fpf.GetStringFrom (format, nfi, value);
}
-
}
-
}
//
// System.DuplicateWaitObjectException.cs
//
-// Author:
+// Authors:
// Joe Shaw (joe@ximian.com)
// Duncan Mak (duncan@ximian.com)
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
-using System.Globalization;
using System.Runtime.Serialization;
-namespace System {
-
+namespace System
+{
[Serializable]
- public class DuplicateWaitObjectException : ArgumentException {
+ public class DuplicateWaitObjectException : ArgumentException
+ {
// Constructors
public DuplicateWaitObjectException ()
- : base (Locale.GetText ("Duplicate objects in argument"))
+ : base (Locale.GetText ("Duplicate objects in argument."))
{
}
- public DuplicateWaitObjectException (string param_name)
- : base (Locale.GetText ("Duplicate objects in argument"), param_name)
+ public DuplicateWaitObjectException (string parameterName)
+ : base (Locale.GetText ("Duplicate objects in argument."), parameterName)
{
}
- public DuplicateWaitObjectException (string param_name, string message)
- : base (message, param_name)
+ public DuplicateWaitObjectException (string parameterName, string message)
+ : base (message, parameterName)
{
}
// System.EntryPointNotFoundException.cs
//
// Author:
-// Duncan Mak (duncan@ximian.com)
+// Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Ximian, Inc. http://www.ximian.com
//
-using System;
-using System.Globalization;
using System.Runtime.Serialization;
namespace System
// Constructors
public EntryPointNotFoundException ()
: base (Locale.GetText ("Cannot load class because of missing entry method."))
- {
- }
-
+ {
+ }
+
public EntryPointNotFoundException (string message)
: base (message)
- {
- }
-
- protected EntryPointNotFoundException (SerializationInfo info,
- StreamingContext context)
+ {
+ }
+
+ protected EntryPointNotFoundException (SerializationInfo info, StreamingContext context)
: base (info, context)
- {
- }
-
+ {
+ }
+
public EntryPointNotFoundException (string message, Exception innerException)
:base (message, innerException)
- {
- }
-
+ {
+ }
}
}
using System.Globalization;
using System.Runtime.CompilerServices;
-namespace System {
- internal struct MonoEnumInfo {
+namespace System
+{
+ internal struct MonoEnumInfo
+ {
internal Type utype;
internal Array values;
internal string[] names;
static Hashtable cache;
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern void get_enum_info (Type enumType, out MonoEnumInfo info);
private MonoEnumInfo (MonoEnumInfo other)
values = other.values;
names = other.names;
}
-
+
internal static void GetInfo (Type enumType, out MonoEnumInfo info)
{
if (cache == null)
}
};
+ [MonoTODO ("Locale.GetText")]
[Serializable]
- public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable {
-
- internal Enum () {
+ public abstract class Enum : ValueType, IComparable, IConvertible, IFormattable
+ {
+ internal Enum ()
+ {
}
-
- // IConvertible methods Start -->
- public TypeCode GetTypeCode () {
+ // IConvertible methods Start -->
+ public TypeCode GetTypeCode ()
+ {
MonoEnumInfo info;
MonoEnumInfo.GetInfo (this.GetType (), out info);
return Type.GetTypeCode (info.utype);
return Convert.ToInt64 (get_value (), provider);
}
- [CLSCompliant(false)]
+ [CLSCompliant (false)]
sbyte IConvertible.ToSByte (IFormatProvider provider)
{
return Convert.ToSByte (get_value (), provider);
{
return Convert.ToType (get_value (), conversionType, provider);
}
-
- [CLSCompliant(false)]
+
+ [CLSCompliant (false)]
ushort IConvertible.ToUInt16 (IFormatProvider provider)
{
return Convert.ToUInt16 (get_value (), provider);
}
- [CLSCompliant(false)]
+ [CLSCompliant (false)]
uint IConvertible.ToUInt32 (IFormatProvider provider)
{
return Convert.ToUInt32 (get_value (), provider);
}
- [CLSCompliant(false)]
+ [CLSCompliant (false)]
ulong IConvertible.ToUInt64 (IFormatProvider provider)
{
return Convert.ToUInt64 (get_value (), provider);
}
-
// <-- End IConvertible methods
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern object get_value ();
-
- public static Array GetValues (Type enumType) {
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
+
+ public static Array GetValues (Type enumType)
+ {
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
MonoEnumInfo.GetInfo (enumType, out info);
return (Array) info.values.Clone ();
}
-
- public static string[] GetNames (Type enumType) {
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
+
+ public static string[] GetNames (Type enumType)
+ {
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
MonoEnumInfo.GetInfo (enumType, out info);
return (string []) info.names.Clone ();
}
-
- public static string GetName (Type enumType, object value) {
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
- if (null == value)
- throw new ArgumentNullException ("value cannot be null.");
+
+ public static string GetName (Type enumType, object value)
+ {
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
+ if (value == null)
+ throw new ArgumentNullException ("value");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
int i;
value = ToObject (enumType, value);
MonoEnumInfo.GetInfo (enumType, out info);
- for (i = 0; i < info.values.Length; ++i) {
+ for (i = 0; i < info.values.Length; ++i) {
if (value.Equals (info.values.GetValue (i)))
return info.names [i];
}
return null;
}
-
- public static bool IsDefined (Type enumType, object value) {
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
- if (null == value)
- throw new ArgumentNullException ("value cannot be null.");
+
+ public static bool IsDefined (Type enumType, object value)
+ {
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
+ if (value == null)
+ throw new ArgumentNullException ("value");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
int i;
value = ToObject (enumType, value);
MonoEnumInfo.GetInfo (enumType, out info);
- for (i = 0; i < info.values.Length; ++i) {
+ for (i = 0; i < info.values.Length; ++i) {
if (value.Equals (info.values.GetValue (i)))
return true;
}
+ "It must be type String or the same type as the underlying type"
+ "of the Enum.");
}
-
-
}
-
- public static Type GetUnderlyingType (Type enumType) {
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
+
+ public static Type GetUnderlyingType (Type enumType)
+ {
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
public static object Parse (Type enumType, string value, bool ignoreCase)
{
- if (null == enumType)
- throw new ArgumentNullException ("enumType cannot be null.");
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
- if (null == value)
- throw new ArgumentNullException ("value cannot be null.");
+ if (value == null)
+ throw new ArgumentNullException ("value");
if (!enumType.IsEnum)
throw new ArgumentException ("enumType is not an Enum type.");
try {
// Attempt to convert to numeric type
- return ToObject(enumType, Convert.ChangeType (value, typeCode) );
+ return ToObject (enumType, Convert.ChangeType (value, typeCode) );
} catch {}
- string[] names = value.Split(new char[] {','});
+ string[] names = value.Split (new char[] {','});
for (i = 0; i < names.Length; ++i)
names [i] = names [i].Trim ();
foreach (string name in names) {
bool found = false;
- for (i = 0; i < info.values.Length; ++i) {
+ for (i = 0; i < info.values.Length; ++i) {
if (String.Compare (name, info.names [i], ignoreCase, CultureInfo.InvariantCulture) == 0) {
switch (typeCode) {
case TypeCode.Byte:
}
}
if (!found)
- throw new ArgumentException ("The requested value was not found");
+ throw new ArgumentException ("The requested value was not found.");
}
- return ToObject(enumType, retVal);
+ return ToObject (enumType, retVal);
}
/// <summary>
if (obj == null)
return 1;
- thisType = this.GetType();
- if (obj.GetType() != thisType){
- throw new ArgumentException(
+ thisType = this.GetType ();
+ if (obj.GetType() != thisType) {
+ throw new ArgumentException (
"Object must be the same type as the "
+ "enum. The type passed in was "
- + obj.GetType().ToString()
+ + obj.GetType().ToString ()
+ "; the enum type was "
- + thisType.ToString() + ".");
+ + thisType.ToString () + ".");
}
object value1, value2;
value1 = this.get_value ();
- value2 = ((Enum)obj).get_value();
+ value2 = ((Enum)obj).get_value ();
return ((IComparable)value1).CompareTo (value2);
}
-
+
public override string ToString ()
{
return ToString ("G", null);
{
// provider is not used for Enums
- if (format == String.Empty || format == null){
+ if (format == String.Empty || format == null) {
format = "G";
}
return Format (this.GetType(), this.get_value (), format);
}
- public static object ToObject(Type enumType, byte value)
+ public static object ToObject (Type enumType, byte value)
{
return ToObject (enumType, (object)value);
}
-
- public static object ToObject(Type enumType, short value)
+
+ public static object ToObject (Type enumType, short value)
{
return ToObject (enumType, (object)value);
}
- public static object ToObject(Type enumType, int value)
+
+ public static object ToObject (Type enumType, int value)
{
return ToObject (enumType, (object)value);
}
- public static object ToObject(Type enumType, long value)
+
+ public static object ToObject (Type enumType, long value)
{
return ToObject (enumType, (object)value);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern object ToObject(Type enumType, object value);
+ public static extern object ToObject (Type enumType, object value);
- [CLSCompliant(false)]
- public static object ToObject(Type enumType, sbyte value)
+ [CLSCompliant (false)]
+ public static object ToObject (Type enumType, sbyte value)
{
return ToObject (enumType, (object)value);
}
- [CLSCompliant(false)]
- public static object ToObject(Type enumType, ushort value)
+
+ [CLSCompliant (false)]
+ public static object ToObject (Type enumType, ushort value)
{
return ToObject (enumType, (object)value);
}
- [CLSCompliant(false)]
- public static object ToObject(Type enumType, uint value)
+
+ [CLSCompliant (false)]
+ public static object ToObject (Type enumType, uint value)
{
return ToObject (enumType, (object)value);
}
- [CLSCompliant(false)]
- public static object ToObject(Type enumType, ulong value)
+
+ [CLSCompliant (false)]
+ public static object ToObject (Type enumType, ulong value)
{
return ToObject (enumType, (object)value);
}
public override bool Equals (object obj)
{
- if (null == obj || !(obj is Enum))
+ if (obj == null || !(obj is Enum))
return false;
- if (obj.GetType() != this.GetType())
+ if (obj.GetType() != this.GetType ())
return false;
object v1 = this.get_value ();
// 8, if it's culture specific, or what. This works for me.
const string format = "x8";
- switch (Type.GetTypeCode(enumType)) {
+ switch (Type.GetTypeCode (enumType)) {
case TypeCode.Char:
// Char doesn't support ToString(format), so convert to an int and
// use that...
char v = (char) value;
- return Convert.ToInt32(v).ToString(format);
+ return Convert.ToInt32 (v).ToString(format);
case TypeCode.SByte:
- return ((sbyte)value).ToString(format);
+ return ((sbyte)value).ToString (format);
case TypeCode.Byte:
- return ((byte)value).ToString(format);
+ return ((byte)value).ToString (format);
case TypeCode.Int16:
- return ((short)value).ToString(format);
+ return ((short)value).ToString (format);
case TypeCode.UInt16:
- return ((ushort)value).ToString(format);
+ return ((ushort)value).ToString (format);
case TypeCode.Int32:
- return ((int)value).ToString(format);
+ return ((int)value).ToString (format);
case TypeCode.UInt32:
- return ((uint)value).ToString(format);
+ return ((uint)value).ToString (format);
case TypeCode.Int64:
- return ((long)value).ToString(format);
+ return ((long)value).ToString (format);
case TypeCode.UInt64:
- return ((ulong)value).ToString(format);
+ return ((ulong)value).ToString (format);
default:
- throw new Exception ("invalid type code for enumeration");
+ throw new Exception ("Invalid type code for enumeration.");
}
}
retVal = GetName (enumType, value);
if (retVal == null)
retVal = asString;
-
return retVal;
}
// This is ugly, yes. We need to handle the different integer
// types for enums. If someone else has a better idea, be my guest.
- switch (((Enum)info.values.GetValue (0)).GetTypeCode()) {
+ switch (((Enum)info.values.GetValue (0)).GetTypeCode ()) {
case TypeCode.SByte: {
sbyte flags = (sbyte) value;
sbyte enumValue;
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (flags != 0) return asString;
}
break;
- case TypeCode.Byte:{
+ case TypeCode.Byte: {
byte flags = (byte) value;
byte enumValue;
for (int i = info.values.Length - 1; i >= 0; i--) {
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
if (i == 0 && enumValue == 0)
continue;
- if ((flags & enumValue) == enumValue){
+ if ((flags & enumValue) == enumValue) {
retVal = info.names[i] + (retVal == String.Empty ? "" : ", ") + retVal;
flags -= enumValue;
}
public static string Format (Type enumType, object value, string format)
{
- if (null == enumType)
- throw new ArgumentNullException("enumType cannot be null");
- if (null == value)
- throw new ArgumentNullException("value cannot be null");
- if (null == format)
- throw new ArgumentNullException("format cannot be null");
+ if (enumType == null)
+ throw new ArgumentNullException ("enumType");
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ if (format == null)
+ throw new ArgumentNullException ("format");
if (!enumType.IsEnum)
- throw new ArgumentException("enumType is not an Enum Type");
+ throw new ArgumentException ("enumType is not an Enum Type.");
Type vType = value.GetType();
- if (vType != enumType && vType != Enum.GetUnderlyingType(enumType))
- throw new ArgumentException();
+ if (vType != enumType && vType != Enum.GetUnderlyingType (enumType))
+ throw new ArgumentException ();
if (format.Length != 1)
throw new FormatException ("Format String can be only \"G\",\"g\",\"X\"," +
- "\"x\",\"F\",\"f\",\"D\" or \"d\".");
+ "\"x\",\"F\",\"f\",\"D\" or \"d\".");
char formatChar = format [0];
string retVal;
retVal = "";
switch (formatChar) {
- case 'X':
- case 'x':
+ case 'X':
+ case 'x':
retVal = FormatSpecifier_X (enumType, value);
break;
- case 'D':
- case 'd':
+ case 'D':
+ case 'd':
if (Enum.GetUnderlyingType (enumType) == typeof (ulong)) {
ulong ulongValue = Convert.ToUInt64 (value);
retVal = ulongValue.ToString ();
retVal = longValue.ToString ();
}
break;
- default:
+ default:
throw new FormatException ("Format String can be only \"G\",\"g\",\"X\"," +
- "\"x\",\"F\",\"f\",\"D\" or \"d\".");
+ "\"x\",\"F\",\"f\",\"D\" or \"d\".");
}
-
return retVal;
}
}
//
-// System._AppDomain
+// System.AppDomain.cs
//
// Author:
// Duco Fijma (duco@lorentz.xs4all.nl)
namespace System
{
+ [CLSCompliant (false)]
+ [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid ("05F696DC-2B29-3663-AD8B-C4389CF2A713")]
+ public interface _AppDomain
+ {
+ string BaseDirectory {get; }
+ string DynamicDirectory {get; }
+ Evidence Evidence {get; }
+ string FriendlyName {get; }
+ string RelativeSearchPath {get; }
+ bool ShadowCopyFiles {get; }
-[CLSCompliant(false)]
-[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
-[Guid ("05F696DC-2B29-3663-AD8B-C4389CF2A713")]
-public interface _AppDomain {
+ void AppendPrivatePath (string path);
+ void ClearPrivatePath ();
+ void ClearShadowCopyPath ();
- string BaseDirectory {get; }
- string DynamicDirectory {get; }
- Evidence Evidence {get; }
- string FriendlyName {get; }
- string RelativeSearchPath {get; }
- bool ShadowCopyFiles {get; }
+ ObjectHandle CreateInstance (string assemblyName, string typeName);
+ ObjectHandle CreateInstance (string assemblyName, string typeName, object[] activationAttributes);
+ ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
+ BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
+ object[] activationAttributes, Evidence securityAttribtutes);
- void AppendPrivatePath (string path);
- void ClearPrivatePath ();
- void ClearShadowCopyPath ();
+ ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName);
+ ObjectHandle CreateInstanceFrom (string assemblyName, string typeName, object[] activationAttributes);
+ ObjectHandle CreateInstanceFrom (string assemblyName, string typeName, bool ignoreCase,
+ BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture,
+ object[] activationAttributes, Evidence securityAttribtutes);
- ObjectHandle CreateInstance (string assemblyName, string typeName);
- ObjectHandle CreateInstance (
- string assemblyName,
- string typeName,
- object[] activationAttributes);
- ObjectHandle CreateInstance (
- string assemblyName,
- string typeName,
- bool ignoreCase,
- BindingFlags bindingAttr,
- Binder binder,
- object[] args,
- CultureInfo culture,
- object[] activationAttributes,
- Evidence securityAttribtutes);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, Evidence evidence);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir, Evidence evidence);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
+ PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPersmissions);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
+ Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions,
+ PermissionSet refusedPersmissions);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
+ string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPersmissions);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access,
+ string dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions,
+ PermissionSet refusedPersmissions);
+ AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir,
+ Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions,
+ PermissionSet refusedPersmissions, bool isSynchronized);
- ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName);
- ObjectHandle CreateInstanceFrom (
- string assemblyName, string typeName,
- object[] activationAttributes);
- ObjectHandle CreateInstanceFrom (string assemblyName,
- string typeName,
- bool ignoreCase,
- BindingFlags bindingAttr,
- Binder binder,
- object[] args,
- CultureInfo culture,
- object[] activationAttributes,
- Evidence securityAttribtutes);
+ void DoCallBack (CrossAppDomainDelegate theDelegate);
+ bool Equals (object other);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- Evidence evidence);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access, string dir);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- string dir,
- Evidence evidence);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPersmissions);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- Evidence evidence,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPersmissions);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- string dir,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPersmissions);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- string dir,
- Evidence evidence,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPersmissions);
- AssemblyBuilder DefineDynamicAssembly (
- AssemblyName name,
- AssemblyBuilderAccess access,
- string dir,
- Evidence evidence,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPersmissions,
- bool isSynchronized);
+ int ExecuteAssembly (string assemblyFile);
+ int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity);
+ int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity, string[] args);
- void DoCallBack (CrossAppDomainDelegate theDelegate);
- bool Equals (object other);
+ Assembly[] GetAssemblies ();
+ object GetData (string name);
+ int GetHashCode();
+ object GetLifetimeService ();
+ Type GetType ();
+ object InitializeLifetimeService ();
- int ExecuteAssembly (string assemblyFile);
- int ExecuteAssembly (string assemblyFile, Evidence assemblySecurity);
- int ExecuteAssembly (
- string assemblyFile,
- Evidence assemblySecurity,
- string[] args);
+ Assembly Load (AssemblyName assemblyRef);
+ Assembly Load (byte[] rawAssembly);
+ Assembly Load (string assemblyString);
+ Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity);
+ Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore);
+ Assembly Load (string assemblyString, Evidence assemblySecurity);
+ Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence);
- Assembly[] GetAssemblies ();
- object GetData (string name);
- int GetHashCode();
- object GetLifetimeService ();
- Type GetType ();
- object InitializeLifetimeService ();
-
- Assembly Load (AssemblyName assemblyRef);
- Assembly Load (byte[] rawAssembly);
- Assembly Load (string assemblyString);
- Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity);
- Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore);
- Assembly Load (string assemblyString, Evidence assemblySecurity);
- Assembly Load (
- byte[] rawAssembly,
- byte[] rawSymbolStore,
- Evidence securityEvidence);
-
- void SetAppDomainPolicy (PolicyLevel domainPolicy);
- void SetCachePath (string s);
- void SetData (string name, object data);
- void SetPrincipalPolicy (PrincipalPolicy policy);
- void SetShadowCopyPath (string s);
- void SetThreadPrincipal (IPrincipal principal);
- string ToString ();
-
- event AssemblyLoadEventHandler AssemblyLoad;
- event ResolveEventHandler AssemblyResolve;
- event EventHandler DomainUnload;
- event EventHandler ProcessExit;
- event ResolveEventHandler ResourceResolve;
- event ResolveEventHandler TypeResolve;
- event UnhandledExceptionEventHandler UnhandledException;
-}
+ void SetAppDomainPolicy (PolicyLevel domainPolicy);
+ void SetCachePath (string s);
+ void SetData (string name, object data);
+ void SetPrincipalPolicy (PrincipalPolicy policy);
+ void SetShadowCopyPath (string s);
+ void SetThreadPrincipal (IPrincipal principal);
+ string ToString ();
+ event AssemblyLoadEventHandler AssemblyLoad;
+ event ResolveEventHandler AssemblyResolve;
+ event EventHandler DomainUnload;
+ event EventHandler ProcessExit;
+ event ResolveEventHandler ResourceResolve;
+ event ResolveEventHandler TypeResolve;
+ event UnhandledExceptionEventHandler UnhandledException;
+ }
}