You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@@ -1,63 +0,0 @@
|
||||
//
|
||||
// System.AccessViolationException.cs
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[Serializable]
|
||||
public class AccessViolationException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80004003);
|
||||
|
||||
// Constructors
|
||||
public AccessViolationException ()
|
||||
: base (Locale.GetText ("Attempted to read or write protected memory. This is often an indication that other memory has been corrupted."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public AccessViolationException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public AccessViolationException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected AccessViolationException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// Action.cs
|
||||
//
|
||||
// Authors:
|
||||
// Ben Maurer (bmaurer@ximian.com)
|
||||
// Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// Copyright (C) 2004, 2010 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.Runtime.CompilerServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
#if MOBILE
|
||||
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
|
||||
#else
|
||||
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
|
||||
#endif
|
||||
public delegate void Action ();
|
||||
|
||||
public delegate void Action <in T> (T obj);
|
||||
|
||||
#if MOBILE
|
||||
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
|
||||
#else
|
||||
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
|
||||
#endif
|
||||
public delegate void Action <in T1, in T2> (T1 arg1, T2 arg2);
|
||||
|
||||
#if MOBILE
|
||||
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
|
||||
#else
|
||||
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
|
||||
#endif
|
||||
public delegate void Action <in T1, in T2, in T3> (T1 arg1, T2 arg2, T3 arg3);
|
||||
|
||||
#if MOBILE
|
||||
[TypeForwardedFrom (Consts.AssemblySystem_Core)]
|
||||
#else
|
||||
[TypeForwardedFrom (Consts.AssemblySystemCore_3_5)]
|
||||
#endif
|
||||
public delegate void Action <in T1, in T2, in T3, in T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
|
||||
|
||||
public delegate void Action <in T1, in T2, in T3, in T4, in T5> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
|
||||
public delegate void Action <in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8> (T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
|
||||
}
|
@@ -1,437 +0,0 @@
|
||||
//
|
||||
// System.Activator.cs
|
||||
//
|
||||
// Authors:
|
||||
// Nick Drochak II (ndrochak@gol.com)
|
||||
// Gonzalo Paniagua (gonzalo@ximian.com)
|
||||
// Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// (C) 2001 Nick Drochak II
|
||||
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
|
||||
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
|
||||
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.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.
|
||||
//
|
||||
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
using System.Security.Policy;
|
||||
using System.Configuration.Assemblies;
|
||||
using System.Text;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Activation;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[ClassInterface (ClassInterfaceType.None)]
|
||||
[ComVisible (true)]
|
||||
[ComDefaultInterface (typeof (_Activator))]
|
||||
public sealed class Activator : _Activator
|
||||
{
|
||||
const BindingFlags _flags = BindingFlags.CreateInstance | BindingFlags.Public | BindingFlags.Instance;
|
||||
const BindingFlags _accessFlags = BindingFlags.DeclaredOnly | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase |
|
||||
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public |
|
||||
BindingFlags.Static;
|
||||
|
||||
private Activator ()
|
||||
{
|
||||
}
|
||||
|
||||
[MonoTODO ("No COM support")]
|
||||
public static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
throw new ArgumentNullException ("assemblyName");
|
||||
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("typeName");
|
||||
|
||||
if (assemblyName.Length == 0)
|
||||
throw new ArgumentException ("assemblyName");
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[MonoTODO("Mono does not support COM")]
|
||||
public static ObjectHandle CreateComInstanceFrom (string assemblyName, string typeName,
|
||||
byte []hashValue, AssemblyHashAlgorithm hashAlgorithm)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
throw new ArgumentNullException ("assemblyName");
|
||||
|
||||
if (typeName == null)
|
||||
throw new ArgumentNullException ("typeName");
|
||||
|
||||
if (assemblyName.Length == 0)
|
||||
throw new ArgumentException ("assemblyName");
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName)
|
||||
{
|
||||
return CreateInstanceFrom (assemblyFile, typeName, null);
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, object [] activationAttributes)
|
||||
{
|
||||
return Activator.CreateInstanceFrom (assemblyFile, typeName, false, _flags, null, null, null,
|
||||
activationAttributes, null);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
|
||||
BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture, object [] activationAttributes,
|
||||
Evidence securityInfo)
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom (assemblyFile, securityInfo);
|
||||
if (assembly == null)
|
||||
return null;
|
||||
|
||||
Type type = assembly.GetType (typeName, true, ignoreCase);
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
object obj = CreateInstance (type, bindingAttr, binder, args, culture, activationAttributes);
|
||||
return (obj != null) ? new ObjectHandle (obj) : null;
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstance (string assemblyName, string typeName)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
|
||||
|
||||
return Activator.CreateInstance (assemblyName, typeName, null);
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstance (string assemblyName, string typeName, object [] activationAttributes)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
assemblyName = Assembly.GetCallingAssembly ().GetName ().Name;
|
||||
|
||||
return Activator.CreateInstance (assemblyName, typeName, false, _flags, null, null, null,
|
||||
activationAttributes, null);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
|
||||
BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture, object [] activationAttributes, Evidence securityInfo)
|
||||
{
|
||||
Assembly assembly = null;
|
||||
if(assemblyName == null)
|
||||
assembly = Assembly.GetCallingAssembly ();
|
||||
else
|
||||
assembly = Assembly.Load (assemblyName, securityInfo);
|
||||
Type type = assembly.GetType (typeName, true, ignoreCase);
|
||||
object obj = CreateInstance (type, bindingAttr, binder, args, culture, activationAttributes);
|
||||
return (obj != null) ? new ObjectHandle (obj) : null;
|
||||
}
|
||||
|
||||
[MonoNotSupported ("no ClickOnce in mono")]
|
||||
public static ObjectHandle CreateInstance (ActivationContext activationContext)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
[MonoNotSupported ("no ClickOnce in mono")]
|
||||
public static ObjectHandle CreateInstance (ActivationContext activationContext, string [] activationCustomData)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
// Cross-domain instance creation
|
||||
|
||||
public static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
return domain.CreateInstanceFrom (assemblyFile, typeName);
|
||||
}
|
||||
|
||||
|
||||
[Obsolete]
|
||||
public static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName,
|
||||
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
|
||||
object [] args, CultureInfo culture,
|
||||
object [] activationAttributes,
|
||||
Evidence securityAttributes)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
|
||||
return domain.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
return domain.CreateInstance (assemblyName, typeName);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName,
|
||||
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
|
||||
object [] args, CultureInfo culture,
|
||||
object [] activationAttributes,
|
||||
Evidence securityAttributes)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
return domain.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
|
||||
}
|
||||
|
||||
public static T CreateInstance <T> ()
|
||||
{
|
||||
return (T) CreateInstance (typeof (T));
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type)
|
||||
{
|
||||
return CreateInstance (type, false);
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type, params object [] args)
|
||||
{
|
||||
return CreateInstance (type, args, EmptyArray<object>.Value);
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type, object [] args, object [] activationAttributes)
|
||||
{
|
||||
return CreateInstance (type, BindingFlags.Default, Binder.DefaultBinder, args, null, activationAttributes);
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type, BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture)
|
||||
{
|
||||
return CreateInstance (type, bindingAttr, binder, args, culture, EmptyArray<object>.Value);
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type, BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture, object [] activationAttributes)
|
||||
{
|
||||
CheckType (type);
|
||||
|
||||
if (type.ContainsGenericParameters)
|
||||
throw new ArgumentException (type + " is an open generic type", "type");
|
||||
|
||||
// It seems to apply the same rules documented for InvokeMember: "If the type of lookup
|
||||
// is omitted, BindingFlags.Public | BindingFlags.Instance will apply".
|
||||
if ((bindingAttr & _accessFlags) == 0)
|
||||
bindingAttr |= BindingFlags.Public | BindingFlags.Instance;
|
||||
|
||||
if (binder == null)
|
||||
binder = Binder.DefaultBinder;
|
||||
|
||||
object state;
|
||||
ConstructorInfo ctor = (ConstructorInfo) binder.BindToMethod (bindingAttr, type.GetConstructors (bindingAttr), ref args, null, null, null, out state);
|
||||
|
||||
if (ctor == null) {
|
||||
// Not sure about this
|
||||
if (type.IsValueType && (args == null || args.Length == 0)) {
|
||||
return CreateInstanceInternal (type);
|
||||
}
|
||||
|
||||
var sb = new StringBuilder ();
|
||||
if (args != null) {
|
||||
for (int i = 0; i < args.Length; i++) {
|
||||
if (i > 0)
|
||||
sb.Append (", ");
|
||||
|
||||
var argument = args [i];
|
||||
var arg_type = argument != null ? argument.GetType () : null;
|
||||
sb.Append (arg_type != null ? arg_type.ToString () : "(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
throw new MissingMethodException (String.Format (Locale.GetText ("No constructor found for {0}::.ctor({1})"),
|
||||
type.FullName, sb));
|
||||
}
|
||||
|
||||
CheckAbstractType (type);
|
||||
|
||||
if (activationAttributes != null && activationAttributes.Length > 0) {
|
||||
#if DISABLE_REMOTING
|
||||
throw new NotSupportedException ("Activation attributes are not supported");
|
||||
#else
|
||||
if (!type.IsMarshalByRef) {
|
||||
string msg = Locale.GetText ("Type '{0}' doesn't derive from MarshalByRefObject.", type.FullName);
|
||||
throw new NotSupportedException (msg);
|
||||
}
|
||||
object newOb = ActivationServices.CreateProxyFromAttributes (type, activationAttributes);
|
||||
if (newOb != null) {
|
||||
// This returns null
|
||||
ctor.Invoke (newOb, bindingAttr, binder, args, culture);
|
||||
return newOb;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return ctor.Invoke (bindingAttr, binder, args, culture);
|
||||
}
|
||||
|
||||
public static object CreateInstance (Type type, bool nonPublic)
|
||||
{
|
||||
CheckType (type);
|
||||
|
||||
if (type.ContainsGenericParameters)
|
||||
throw new ArgumentException (type + " is an open generic type", "type");
|
||||
|
||||
MonoType monoType = type.UnderlyingSystemType as MonoType;
|
||||
if (monoType == null)
|
||||
throw new ArgumentException ("Type must be a type provided by the runtime");
|
||||
|
||||
CheckAbstractType (monoType);
|
||||
|
||||
var ctor = monoType.GetDefaultConstructor ();
|
||||
if (!nonPublic && ctor != null && !ctor.IsPublic) {
|
||||
ctor = null;
|
||||
}
|
||||
|
||||
if (ctor == null) {
|
||||
if (type.IsValueType)
|
||||
return CreateInstanceInternal (type);
|
||||
|
||||
throw new MissingMethodException (Locale.GetText ("Default constructor not found for type " + type.FullName));
|
||||
}
|
||||
|
||||
return ctor.InternalInvoke (null, null);
|
||||
}
|
||||
|
||||
private static void CheckType (Type type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
||||
if ((type == typeof (TypedReference)) || (type == typeof (ArgIterator)) || (type == typeof (void)) ||
|
||||
(type == typeof (RuntimeArgumentHandle))) {
|
||||
string msg = Locale.GetText ("CreateInstance cannot be used to create this type ({0}).", type.FullName);
|
||||
throw new NotSupportedException (msg);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckAbstractType (Type type)
|
||||
{
|
||||
if (type.IsAbstract) {
|
||||
string msg = Locale.GetText ("Cannot create an abstract class '{0}'.", type.FullName);
|
||||
throw new MissingMethodException (msg);
|
||||
}
|
||||
}
|
||||
|
||||
[SecurityPermission (SecurityAction.LinkDemand, RemotingConfiguration = true)]
|
||||
public static object GetObject (Type type, string url)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
||||
return RemotingServices.Connect (type, url);
|
||||
}
|
||||
|
||||
[SecurityPermission (SecurityAction.LinkDemand, RemotingConfiguration = true)]
|
||||
public static object GetObject (Type type, string url, object state)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
|
||||
return RemotingServices.Connect (type, url, state);
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal static extern object CreateInstanceInternal (Type type);
|
||||
|
||||
void _Activator.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Activator.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Activator.GetTypeInfoCount (out uint pcTInfo)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Activator.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
|
||||
IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstance (string assemblyName, string typeName, bool ignoreCase,
|
||||
BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture, object [] activationAttributes)
|
||||
{
|
||||
Assembly assembly = null;
|
||||
if(assemblyName == null)
|
||||
assembly = Assembly.GetCallingAssembly ();
|
||||
else
|
||||
assembly = Assembly.Load (assemblyName);
|
||||
Type type = assembly.GetType (typeName, true, ignoreCase);
|
||||
object obj = CreateInstance (type, bindingAttr, binder, args, culture, activationAttributes);
|
||||
return (obj != null) ? new ObjectHandle (obj) : null;
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstance (AppDomain domain, string assemblyName, string typeName,
|
||||
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
|
||||
object [] args, CultureInfo culture,
|
||||
object [] activationAttributes)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
return domain.CreateInstance (assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes);
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase,
|
||||
BindingFlags bindingAttr, Binder binder, object [] args,
|
||||
CultureInfo culture, object [] activationAttributes)
|
||||
{
|
||||
Assembly assembly = Assembly.LoadFrom (assemblyFile);
|
||||
if (assembly == null)
|
||||
return null;
|
||||
|
||||
Type type = assembly.GetType (typeName, true, ignoreCase);
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
object obj = CreateInstance (type, bindingAttr, binder, args, culture, activationAttributes);
|
||||
return (obj != null) ? new ObjectHandle (obj) : null;
|
||||
}
|
||||
|
||||
public static ObjectHandle CreateInstanceFrom (AppDomain domain, string assemblyFile, string typeName,
|
||||
bool ignoreCase, BindingFlags bindingAttr, Binder binder,
|
||||
object [] args, CultureInfo culture,
|
||||
object [] activationAttributes)
|
||||
{
|
||||
if (domain == null)
|
||||
throw new ArgumentNullException ("domain");
|
||||
|
||||
return domain.CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes);
|
||||
}
|
||||
}
|
||||
}
|
@@ -36,7 +36,6 @@ namespace System {
|
||||
|
||||
static readonly Func<SynchronizationContext> getDefaultSyncContext;
|
||||
static readonly Func<string> getDefaultTimeZone;
|
||||
static readonly Func<TimeZone> getCurrentSystemTimeZone;
|
||||
|
||||
static AndroidPlatform ()
|
||||
{
|
||||
@@ -51,11 +50,6 @@ namespace System {
|
||||
Delegate.CreateDelegate (typeof(Func<string>),
|
||||
androidRuntime.GetMethod ("GetDefaultTimeZone",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic));
|
||||
|
||||
MethodInfo mi = androidRuntime.GetMethod ("GetCurrentSystemTimeZone",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
if (mi != null)
|
||||
getCurrentSystemTimeZone = (Func<TimeZone>) Delegate.CreateDelegate (typeof(Func<TimeZone>), mi);
|
||||
}
|
||||
|
||||
internal static SynchronizationContext GetDefaultSyncContext ()
|
||||
@@ -67,13 +61,6 @@ namespace System {
|
||||
{
|
||||
return getDefaultTimeZone ();
|
||||
}
|
||||
|
||||
internal static TimeZone GetCurrentSystemTimeZone ()
|
||||
{
|
||||
if (getCurrentSystemTimeZone == null)
|
||||
return null;
|
||||
return getCurrentSystemTimeZone ();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -324,6 +324,46 @@ namespace System {
|
||||
}
|
||||
#endif
|
||||
|
||||
internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName, string typeName)
|
||||
{
|
||||
return CreateInstance(assemblyName, typeName);
|
||||
}
|
||||
|
||||
internal ObjectHandle InternalCreateInstanceWithNoSecurity (string assemblyName,
|
||||
string typeName,
|
||||
bool ignoreCase,
|
||||
BindingFlags bindingAttr,
|
||||
Binder binder,
|
||||
Object[] args,
|
||||
CultureInfo culture,
|
||||
Object[] activationAttributes,
|
||||
Evidence securityAttributes)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
return CreateInstance(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
||||
internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName, string typeName)
|
||||
{
|
||||
return CreateInstanceFrom(assemblyName, typeName);
|
||||
}
|
||||
|
||||
internal ObjectHandle InternalCreateInstanceFromWithNoSecurity (string assemblyName,
|
||||
string typeName,
|
||||
bool ignoreCase,
|
||||
BindingFlags bindingAttr,
|
||||
Binder binder,
|
||||
Object[] args,
|
||||
CultureInfo culture,
|
||||
Object[] activationAttributes,
|
||||
Evidence securityAttributes)
|
||||
{
|
||||
#pragma warning disable 618
|
||||
return CreateInstanceFrom(assemblyName, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, securityAttributes);
|
||||
#pragma warning restore 618
|
||||
}
|
||||
|
||||
public ObjectHandle CreateInstance (string assemblyName, string typeName)
|
||||
{
|
||||
if (assemblyName == null)
|
||||
|
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// System.AppDomainUnloadedException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Duncan Mak (duncan@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// 2002 (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class AppDomainUnloadedException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80131014);
|
||||
|
||||
// Constructors
|
||||
public AppDomainUnloadedException ()
|
||||
: base (Locale.GetText ("Can't access an unloaded application domain."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public AppDomainUnloadedException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public AppDomainUnloadedException (string message, Exception innerException)
|
||||
:base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected AppDomainUnloadedException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
//
|
||||
// System.ApplicationException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Miguel de Icaza (miguel@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class ApplicationException : Exception
|
||||
{
|
||||
const int Result = unchecked ((int)0x80131600);
|
||||
|
||||
// Constructors
|
||||
public ApplicationException ()
|
||||
: base (Locale.GetText ("An application exception has occurred."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ApplicationException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ApplicationException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ApplicationException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
//
|
||||
// System.ApplicationId class
|
||||
//
|
||||
// Author:
|
||||
// Sebastien Pouliot <sebastien@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System {
|
||||
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public sealed class ApplicationId {
|
||||
|
||||
private byte[] _token;
|
||||
private string _name;
|
||||
private Version _version;
|
||||
private string _proc;
|
||||
private string _culture;
|
||||
|
||||
public ApplicationId (byte[] publicKeyToken, string name, Version version, string processorArchitecture, string culture)
|
||||
{
|
||||
if (publicKeyToken == null)
|
||||
throw new ArgumentNullException ("publicKeyToken");
|
||||
if (name == null)
|
||||
throw new ArgumentNullException ("name");
|
||||
if (version == null)
|
||||
throw new ArgumentNullException ("version");
|
||||
|
||||
_token = (byte[]) publicKeyToken.Clone ();
|
||||
_name = name;
|
||||
_version = version;
|
||||
_proc = processorArchitecture;
|
||||
_culture = culture;
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
public string Culture {
|
||||
get { return _culture; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get { return _name; }
|
||||
}
|
||||
|
||||
public string ProcessorArchitecture {
|
||||
get { return _proc; }
|
||||
}
|
||||
|
||||
public byte[] PublicKeyToken {
|
||||
get { return (byte[]) _token.Clone (); }
|
||||
}
|
||||
|
||||
public Version Version {
|
||||
get { return _version; }
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
public ApplicationId Copy ()
|
||||
{
|
||||
return new ApplicationId (_token, _name, _version, _proc, _culture);
|
||||
}
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (o == null)
|
||||
return false;
|
||||
ApplicationId appid = (o as ApplicationId);
|
||||
if (appid == null)
|
||||
return false;
|
||||
if (_name != appid._name)
|
||||
return false;
|
||||
if (_proc != appid._proc)
|
||||
return false;
|
||||
if (_culture != appid._culture)
|
||||
return false;
|
||||
if (!_version.Equals (appid._version))
|
||||
return false;
|
||||
if (_token.Length != appid._token.Length)
|
||||
return false;
|
||||
for (int i=0; i < _token.Length; i++)
|
||||
if (_token [i] != appid._token [i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
int code = _name.GetHashCode () ^ _version.GetHashCode ();
|
||||
for (int i=0; i < _token.Length; i++)
|
||||
code ^= _token [i];
|
||||
// ProcessorArchitecture and Culture aren't part of the hash code
|
||||
// Confirmed by Microsoft in FDBK13339
|
||||
return code;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
sb.Append (_name);
|
||||
if (_culture != null)
|
||||
sb.AppendFormat (", culture=\"{0}\"", _culture);
|
||||
sb.AppendFormat (", version=\"{0}\", publicKeyToken=\"", _version);
|
||||
for (int i=0; i < _token.Length; i++)
|
||||
sb.Append (_token [i].ToString ("X2"));
|
||||
if (_proc != null)
|
||||
sb.AppendFormat ("\", processorArchitecture =\"{0}\"", _proc);
|
||||
else
|
||||
sb.Append ("\"");
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
//
|
||||
// System.ArgumentException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
public class ArgumentException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80070057);
|
||||
|
||||
private string param_name;
|
||||
|
||||
// Constructors
|
||||
public ArgumentException ()
|
||||
: base (Locale.GetText ("Value does not fall within the expected range."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentException (string message, string paramName)
|
||||
: base (message)
|
||||
{
|
||||
this.param_name = paramName;
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentException (string message, string paramName, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
this.param_name = paramName;
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ArgumentException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
param_name = info.GetString ("ParamName");
|
||||
}
|
||||
|
||||
// Properties
|
||||
public virtual string ParamName {
|
||||
get {
|
||||
return param_name;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Message {
|
||||
get {
|
||||
if (ParamName != null && ParamName.Length != 0)
|
||||
return base.Message + Environment.NewLine
|
||||
+ Locale.GetText ("Parameter name: ")
|
||||
+ ParamName;
|
||||
return base.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData (info, context);
|
||||
info.AddValue ("ParamName", ParamName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
//
|
||||
// System.ArgumentNullException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class ArgumentNullException : ArgumentException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80004003);
|
||||
|
||||
// Constructors
|
||||
public ArgumentNullException ()
|
||||
: base (Locale.GetText ("Argument cannot be null."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentNullException (string paramName)
|
||||
: base (Locale.GetText ("Argument cannot be null."), paramName)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentNullException (string paramName, string message)
|
||||
: base (message, paramName)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentNullException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ArgumentNullException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
//
|
||||
// System.ArgumentOutOfRangeException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Duncan Mak (duncan@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class ArgumentOutOfRangeException : ArgumentException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80131502);
|
||||
|
||||
private object actual_value;
|
||||
|
||||
// Constructors
|
||||
public ArgumentOutOfRangeException ()
|
||||
: base (Locale.GetText ("Argument is out of range."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentOutOfRangeException (string paramName)
|
||||
: base (Locale.GetText ("Argument is out of range."), paramName)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentOutOfRangeException (string paramName, string message)
|
||||
: base (message, paramName)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArgumentOutOfRangeException (string paramName, object actualValue, string message)
|
||||
: base (message, paramName)
|
||||
{
|
||||
this.actual_value = actualValue;
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ArgumentOutOfRangeException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
actual_value = info.GetString ("ActualValue");
|
||||
}
|
||||
|
||||
public ArgumentOutOfRangeException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
// Properties
|
||||
public virtual object ActualValue {
|
||||
get {
|
||||
return actual_value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Message {
|
||||
get {
|
||||
string basemsg = base.Message;
|
||||
if (actual_value == null)
|
||||
return basemsg;
|
||||
return basemsg + Environment.NewLine + actual_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
public override void GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData (info, context);
|
||||
info.AddValue ("ActualValue", actual_value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// System.ArithmeticException.cs
|
||||
//
|
||||
// Author:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Duncan Mak (duncan@ximian.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class ArithmeticException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80070216);
|
||||
|
||||
// Constructors
|
||||
public ArithmeticException ()
|
||||
: base (Locale.GetText ("Overflow or underflow in the arithmetic operation."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArithmeticException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArithmeticException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ArithmeticException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -653,6 +653,21 @@ namespace System
|
||||
return CreateInstance (elementType, length);
|
||||
}
|
||||
|
||||
internal static Array UnsafeCreateInstance(Type elementType, int[] lengths, int[] lowerBounds)
|
||||
{
|
||||
return CreateInstance(elementType, lengths, lowerBounds);
|
||||
}
|
||||
|
||||
internal static Array UnsafeCreateInstance (Type elementType, int length1, int length2)
|
||||
{
|
||||
return CreateInstance (elementType, length1, length2);
|
||||
}
|
||||
|
||||
internal static Array UnsafeCreateInstance (Type elementType, params int[] lengths)
|
||||
{
|
||||
return CreateInstance(elementType, lengths);
|
||||
}
|
||||
|
||||
public static Array CreateInstance (Type elementType, int length)
|
||||
{
|
||||
int[] lengths = {length};
|
||||
@@ -686,8 +701,8 @@ namespace System
|
||||
|
||||
int[] bounds = null;
|
||||
|
||||
elementType = elementType.UnderlyingSystemType;
|
||||
if (!elementType.IsSystemType)
|
||||
elementType = elementType.UnderlyingSystemType as RuntimeType;
|
||||
if (elementType == null)
|
||||
throw new ArgumentException ("Type must be a type provided by the runtime.", "elementType");
|
||||
if (elementType.Equals (typeof (void)))
|
||||
throw new NotSupportedException ("Array type can not be void");
|
||||
@@ -710,8 +725,8 @@ namespace System
|
||||
if (lowerBounds == null)
|
||||
throw new ArgumentNullException ("lowerBounds");
|
||||
|
||||
elementType = elementType.UnderlyingSystemType;
|
||||
if (!elementType.IsSystemType)
|
||||
elementType = elementType.UnderlyingSystemType as RuntimeType;
|
||||
if (elementType == null)
|
||||
throw new ArgumentException ("Type must be a type provided by the runtime.", "elementType");
|
||||
if (elementType.Equals (typeof (void)))
|
||||
throw new NotSupportedException ("Array type can not be void");
|
||||
@@ -3030,7 +3045,7 @@ namespace System
|
||||
if (count < 0 || startIndex < array.GetLowerBound (0) || startIndex - 1 > array.GetUpperBound (0) - count)
|
||||
throw new ArgumentOutOfRangeException ();
|
||||
|
||||
return EqualityComparer<T>.Default.IndexOf (array, value, startIndex, startIndex + count);
|
||||
return EqualityComparer<T>.Default.IndexOf (array, value, startIndex, count);
|
||||
}
|
||||
|
||||
public static int LastIndexOf<T> (T [] array, T value)
|
||||
|
@@ -1,69 +0,0 @@
|
||||
//
|
||||
// System.ArrayTypeMismatchException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Joe Shaw (joe@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class ArrayTypeMismatchException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x80131503);
|
||||
|
||||
// Constructors
|
||||
public ArrayTypeMismatchException ()
|
||||
: base (Locale.GetText ("Source array type cannot be assigned to destination array type."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArrayTypeMismatchException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public ArrayTypeMismatchException (string message, Exception innerException)
|
||||
: base (message, innerException)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected ArrayTypeMismatchException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// System.AsyncCallback.cs
|
||||
//
|
||||
// Author:
|
||||
// Paolo Molaro (lupus@ximian.com)
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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
|
||||
{
|
||||
[System.Runtime.InteropServices.ComVisible (true)]
|
||||
[Serializable]
|
||||
public delegate void AsyncCallback (IAsyncResult ar);
|
||||
}
|
@@ -1,450 +0,0 @@
|
||||
//
|
||||
// System.Attribute.cs
|
||||
//
|
||||
// Authors:
|
||||
// Miguel de Icaza (miguel@ximian.com) - Original
|
||||
// Nick D. Drochak II (ndrochak@gol.com) - Implemented most of the guts
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
//
|
||||
// (C) 2002, 2003 Ximian, Inc. http://www.ximian.com
|
||||
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[AttributeUsage (AttributeTargets.All)]
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
[ComDefaultInterface (typeof (_Attribute))]
|
||||
[ClassInterfaceAttribute (ClassInterfaceType.None)]
|
||||
#if MOBILE
|
||||
public abstract class Attribute {
|
||||
#else
|
||||
public abstract class Attribute : _Attribute {
|
||||
#endif
|
||||
protected Attribute ()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual object TypeId {
|
||||
get {
|
||||
// Derived classes should override this default behaviour as appropriate
|
||||
return this.GetType ();
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckParameters (object element, Type attributeType)
|
||||
{
|
||||
// neither parameter is allowed to be null
|
||||
if (element == null)
|
||||
throw new ArgumentNullException ("element");
|
||||
|
||||
if (attributeType == null)
|
||||
throw new ArgumentNullException ("attributeType");
|
||||
|
||||
if (!typeof (Attribute).IsAssignableFrom (attributeType))
|
||||
throw new ArgumentException (Locale.GetText (
|
||||
"Type is not derived from System.Attribute."), "attributeType");
|
||||
}
|
||||
|
||||
private static Attribute FindAttribute (object[] attributes)
|
||||
{
|
||||
// if there exists more than one attribute of the given type, throw an exception
|
||||
if (attributes.Length > 1) {
|
||||
throw new AmbiguousMatchException (Locale.GetText (
|
||||
"<element> has more than one attribute of type <attribute_type>"));
|
||||
}
|
||||
|
||||
if (attributes.Length < 1)
|
||||
return null;
|
||||
|
||||
// tested above for '> 1' and and '< 1', so only '== 1' is left,
|
||||
// i.e. we found the attribute
|
||||
return (Attribute) attributes[0];
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (ParameterInfo element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttribute (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (MemberInfo element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttribute (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (Assembly element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttribute (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (Module element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttribute (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (Module element, Type attributeType, bool inherit)
|
||||
{
|
||||
// neither parameter is allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
// Module inheritance hierarchies CAN NOT be searched for attributes, so the second
|
||||
// parameter of GetCustomAttributes () is IGNORED.
|
||||
object[] attributes = element.GetCustomAttributes (attributeType, inherit);
|
||||
|
||||
return FindAttribute (attributes);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (Assembly element, Type attributeType, bool inherit)
|
||||
{
|
||||
// neither parameter is allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
// Assembly inheritance hierarchies CAN NOT be searched for attributes, so the second
|
||||
// parameter of GetCustomAttributes () is IGNORED.
|
||||
object[] attributes = element.GetCustomAttributes (attributeType, inherit);
|
||||
|
||||
return FindAttribute (attributes);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (ParameterInfo element, Type attributeType, bool inherit)
|
||||
{
|
||||
// neither parameter is allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
object[] attributes = GetCustomAttributes (element, attributeType, inherit);
|
||||
|
||||
return FindAttribute (attributes);
|
||||
}
|
||||
|
||||
public static Attribute GetCustomAttribute (MemberInfo element, Type attributeType, bool inherit)
|
||||
{
|
||||
// neither parameter is allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
// MemberInfo inheritance hierarchies can be searched for attributes, so the second
|
||||
// parameter of GetCustomAttribute () is respected.
|
||||
return MonoCustomAttrs.GetCustomAttribute (element, attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Assembly element)
|
||||
{
|
||||
return GetCustomAttributes (element, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (ParameterInfo element)
|
||||
{
|
||||
return GetCustomAttributes (element, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (MemberInfo element)
|
||||
{
|
||||
return GetCustomAttributes (element, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Module element)
|
||||
{
|
||||
return GetCustomAttributes (element, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Assembly element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttributes (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Module element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttributes (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (ParameterInfo element, Type attributeType)
|
||||
{
|
||||
return GetCustomAttributes (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (MemberInfo element, Type type)
|
||||
{
|
||||
return GetCustomAttributes (element, type, true);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Assembly element, Type attributeType, bool inherit)
|
||||
{
|
||||
// element parameter is not allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
return (Attribute []) element.GetCustomAttributes (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (ParameterInfo element, Type attributeType, bool inherit)
|
||||
{
|
||||
// element parameter is not allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
Attribute [] attributes;
|
||||
if (inherit && TryGetParamCustomAttributes (element, attributeType, out attributes))
|
||||
return attributes;
|
||||
|
||||
return (Attribute []) element.GetCustomAttributes (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Module element, Type attributeType, bool inherit)
|
||||
{
|
||||
// element parameter is not allowed to be null
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
return (Attribute []) element.GetCustomAttributes (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (MemberInfo element, Type type, bool inherit)
|
||||
{
|
||||
// element parameter is not allowed to be null
|
||||
CheckParameters (element, type);
|
||||
|
||||
// MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
|
||||
// implementation, but not in the Attributes, so directly get the attributes
|
||||
// from MonoCustomAttrs instead of going throught the PropertyInfo's
|
||||
// ICustomAttributeProvider
|
||||
MemberTypes mtype = element.MemberType;
|
||||
if (mtype == MemberTypes.Property)
|
||||
return (Attribute []) MonoCustomAttrs.GetCustomAttributes (element, type, inherit);
|
||||
return (Attribute []) element.GetCustomAttributes (type, inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Module element, bool inherit)
|
||||
{
|
||||
return GetCustomAttributes (element, typeof (Attribute), inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (Assembly element, bool inherit)
|
||||
{
|
||||
return GetCustomAttributes (element, typeof (Attribute), inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (MemberInfo element, bool inherit)
|
||||
{
|
||||
return GetCustomAttributes (element, typeof (Attribute), inherit);
|
||||
}
|
||||
|
||||
public static Attribute[] GetCustomAttributes (ParameterInfo element, bool inherit)
|
||||
{
|
||||
// element parameter is not allowed to be null
|
||||
CheckParameters (element, typeof (Attribute));
|
||||
|
||||
return GetCustomAttributes (element, typeof (Attribute), inherit);
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
int result = GetType ().GetHashCode ();
|
||||
|
||||
FieldInfo[] fields = GetType ().GetFields (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
foreach (FieldInfo field in fields) {
|
||||
object value = field.GetValue (this);
|
||||
result ^= value == null ? 0 : value.GetHashCode ();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual bool IsDefaultAttribute ()
|
||||
{
|
||||
// Derived classes should override this default behaviour as appropriate
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsDefined (Module element, Type attributeType)
|
||||
{
|
||||
return IsDefined (element, attributeType, false);
|
||||
}
|
||||
|
||||
public static bool IsDefined (ParameterInfo element, Type attributeType)
|
||||
{
|
||||
return IsDefined (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static bool IsDefined (MemberInfo element, Type attributeType)
|
||||
{
|
||||
return IsDefined (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static bool IsDefined (Assembly element, Type attributeType)
|
||||
{
|
||||
return IsDefined (element, attributeType, true);
|
||||
}
|
||||
|
||||
public static bool IsDefined (MemberInfo element, Type attributeType, bool inherit)
|
||||
{
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
MemberTypes mtype = element.MemberType;
|
||||
if (mtype != MemberTypes.Constructor && mtype != MemberTypes.Event &&
|
||||
mtype != MemberTypes.Field && mtype != MemberTypes.Method &&
|
||||
mtype != MemberTypes.Property && mtype != MemberTypes.TypeInfo &&
|
||||
mtype != MemberTypes.NestedType)
|
||||
throw new NotSupportedException (Locale.GetText (
|
||||
"Element is not a constructor, method, property, event, type or field."));
|
||||
// MS ignores the inherit param in PropertyInfo's ICustomAttributeProvider
|
||||
// implementation, but not in the Attributes, so directly get the attributes
|
||||
// from MonoCustomAttrs instead of going throught the PropertyInfo's
|
||||
// ICustomAttributeProvider
|
||||
if (mtype == MemberTypes.Property)
|
||||
return MonoCustomAttrs.IsDefined (element, attributeType, inherit);
|
||||
return ((MemberInfo) element).IsDefined (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool IsDefined (Assembly element, Type attributeType, bool inherit)
|
||||
{
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
return element.IsDefined (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool IsDefined (Module element, Type attributeType, bool inherit)
|
||||
{
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
return element.IsDefined (attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool IsDefined (ParameterInfo element, Type attributeType, bool inherit)
|
||||
{
|
||||
CheckParameters (element, attributeType);
|
||||
|
||||
if (element.IsDefined (attributeType, inherit))
|
||||
return true;
|
||||
|
||||
if (inherit)
|
||||
return IsDefinedOnParameter (element, attributeType);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsDefinedOnParameter (ParameterInfo parameter, Type attributeType)
|
||||
{
|
||||
var member = parameter.Member;
|
||||
if (member.MemberType != MemberTypes.Method)
|
||||
return false;
|
||||
|
||||
var method = ((MethodInfo) member).GetBaseMethod ();
|
||||
|
||||
while (true) {
|
||||
var param = method.GetParametersInternal () [parameter.Position];
|
||||
if (param.IsDefined (attributeType, false))
|
||||
return true;
|
||||
|
||||
var base_method = method.GetBaseMethod ();
|
||||
if (base_method == method)
|
||||
break;
|
||||
|
||||
method = base_method;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TryGetParamCustomAttributes (ParameterInfo parameter, Type attributeType, out Attribute [] attributes)
|
||||
{
|
||||
attributes = null;
|
||||
|
||||
if (parameter.Member.MemberType != MemberTypes.Method)
|
||||
return false;
|
||||
|
||||
var method = (MethodInfo) parameter.Member;
|
||||
var definition = method.GetBaseDefinition ();
|
||||
|
||||
if (method == definition)
|
||||
return false;
|
||||
|
||||
var types = new List<Type> ();
|
||||
var custom_attributes = new List<Attribute> ();
|
||||
|
||||
while (true) {
|
||||
var param = method.GetParametersInternal () [parameter.Position];
|
||||
var param_attributes = (Attribute []) param.GetCustomAttributes (attributeType, false);
|
||||
foreach (var param_attribute in param_attributes) {
|
||||
var param_type = param_attribute.GetType ();
|
||||
if (types.Contains (param_type))
|
||||
continue;
|
||||
|
||||
types.Add (param_type);
|
||||
custom_attributes.Add (param_attribute);
|
||||
}
|
||||
|
||||
var base_method = method.GetBaseMethod ();
|
||||
if (base_method == method)
|
||||
break;
|
||||
|
||||
method = base_method;
|
||||
}
|
||||
|
||||
attributes = (Attribute []) Array.CreateInstance (attributeType, custom_attributes.Count);
|
||||
custom_attributes.CopyTo (attributes, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool Match (object obj)
|
||||
{
|
||||
// default action is the same as Equals.
|
||||
// Derived classes should override as appropriate
|
||||
return this.Equals (obj);
|
||||
}
|
||||
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
if (obj == null || !(obj is Attribute))
|
||||
return false;
|
||||
|
||||
//
|
||||
// This is needed because Attribute.Equals does a deep
|
||||
// compare. Ran into this with vbnc
|
||||
//
|
||||
return ValueType.DefaultEquals (this, obj);
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
void _Attribute.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Attribute.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Attribute.GetTypeInfoCount (out uint pcTInfo)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
void _Attribute.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams,
|
||||
IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
//
|
||||
// System.AttributeTargets.cs
|
||||
//
|
||||
// This code was automatically generated from
|
||||
// ECMA CLI XML Library Specification.
|
||||
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
|
||||
// Created: Fri, 7 Sep 2001 16:31:48 UTC
|
||||
// Source file: AllTypes.xml
|
||||
// URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System {
|
||||
|
||||
[ComVisible (true)]
|
||||
[Serializable]
|
||||
[Flags]
|
||||
public enum AttributeTargets
|
||||
{
|
||||
Assembly = 0x00000001,
|
||||
Module = 0x00000002,
|
||||
Class = 0x00000004,
|
||||
Struct = 0x00000008,
|
||||
Enum = 0x00000010,
|
||||
Constructor = 0x00000020,
|
||||
Method = 0x00000040,
|
||||
Property = 0x00000080,
|
||||
Field = 0x00000100,
|
||||
Event = 0x00000200,
|
||||
Interface = 0x00000400,
|
||||
Parameter = 0x00000800,
|
||||
Delegate = 0x00001000,
|
||||
ReturnValue = 0x00002000,
|
||||
|
||||
GenericParameter = 0x00004000,
|
||||
All = Assembly | Module | Class | Struct | Enum | Constructor |
|
||||
Method | Property | Field | Event | Interface | Parameter | Delegate | ReturnValue | GenericParameter
|
||||
}
|
||||
}
|
||||
|
@@ -1,75 +0,0 @@
|
||||
//
|
||||
// System.AttributeUsageAttribute.cs
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza (miguel@ximian.com)
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable, AttributeUsage (AttributeTargets.Class)]
|
||||
[ComVisible (true)]
|
||||
public sealed class AttributeUsageAttribute : Attribute
|
||||
{
|
||||
AttributeTargets valid_on;
|
||||
bool allow_multiple;
|
||||
bool inherited = true;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,147 +0,0 @@
|
||||
//
|
||||
// System.BadImageFormatException.cs
|
||||
//
|
||||
// Authors:
|
||||
// Sean MacIsaac (macisaac@ximian.com)
|
||||
// Duncan Mak (duncan@ximian.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System
|
||||
{
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class BadImageFormatException : SystemException
|
||||
{
|
||||
const int Result = unchecked ((int)0x8007000B);
|
||||
|
||||
// Fields
|
||||
private string fileName;
|
||||
private string fusionLog;
|
||||
|
||||
// Constructors
|
||||
public BadImageFormatException ()
|
||||
: base (Locale.GetText ("Format of the executable (.exe) or library (.dll) is invalid."))
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public BadImageFormatException (string message)
|
||||
: base (message)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
protected BadImageFormatException (SerializationInfo info, StreamingContext context)
|
||||
: base (info, context)
|
||||
{
|
||||
fileName = info.GetString ("BadImageFormat_FileName");
|
||||
fusionLog = info.GetString ("BadImageFormat_FusionLog");
|
||||
}
|
||||
|
||||
public BadImageFormatException (string message, Exception inner)
|
||||
: base (message, inner)
|
||||
{
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public BadImageFormatException (string message, string fileName)
|
||||
: base (message)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
public BadImageFormatException (string message, string fileName, Exception inner)
|
||||
: base (message, inner)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
HResult = Result;
|
||||
}
|
||||
|
||||
// Properties
|
||||
public override string Message
|
||||
{
|
||||
get {
|
||||
if (base.message == null) {
|
||||
return string.Format (
|
||||
"Could not load file or assembly '{0}' or one of"
|
||||
+ " its dependencies. An attempt was made to load"
|
||||
+ " a program with an incorrect format.", fileName);
|
||||
}
|
||||
return base.Message;
|
||||
}
|
||||
}
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get { return fileName; }
|
||||
}
|
||||
|
||||
[MonoTODO ("Probably not entirely correct. fusionLog needs to be set somehow (we are probably missing internal constuctor)")]
|
||||
public string FusionLog {
|
||||
// note: MS runtime throws a SecurityException when the Exception is created
|
||||
// but a FileLoadException once the exception as been thrown. Mono always
|
||||
// throw a SecurityException in both case (anyway fusionLog is currently empty)
|
||||
[SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
|
||||
get { return fusionLog; }
|
||||
}
|
||||
|
||||
// Methods
|
||||
public override void GetObjectData (SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
base.GetObjectData (info, context);
|
||||
info.AddValue ("BadImageFormat_FileName", fileName);
|
||||
info.AddValue ("BadImageFormat_FusionLog", fusionLog);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder (GetType ().FullName);
|
||||
sb.AppendFormat (": {0}", Message);
|
||||
|
||||
if (fileName != null && fileName.Length > 0) {
|
||||
sb.Append (Environment.NewLine);
|
||||
sb.AppendFormat ("File name: '{0}'", fileName);
|
||||
}
|
||||
|
||||
if (this.InnerException != null)
|
||||
sb.AppendFormat (" ---> {0}", InnerException);
|
||||
|
||||
if (this.StackTrace != null) {
|
||||
sb.Append (Environment.NewLine);
|
||||
sb.Append (StackTrace);
|
||||
}
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
//
|
||||
// System.Buffer.cs
|
||||
//
|
||||
// Authors:
|
||||
// Paolo Molaro (lupus@ximian.com)
|
||||
// Dan Lewis (dihlewis@yahoo.co.uk)
|
||||
//
|
||||
// (C) 2001 Ximian, Inc. http://www.ximian.com
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
|
||||
//
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System {
|
||||
[ComVisible (true)]
|
||||
public static class Buffer {
|
||||
|
||||
public static int ByteLength (Array array)
|
||||
{
|
||||
// note: the other methods in this class also use ByteLength to test for
|
||||
// null and non-primitive arguments as a side-effect.
|
||||
|
||||
if (array == null)
|
||||
throw new ArgumentNullException ("array");
|
||||
|
||||
int length = ByteLengthInternal (array);
|
||||
if (length < 0)
|
||||
throw new ArgumentException (Locale.GetText ("Object must be an array of primitives."));
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
public static byte GetByte (Array array, int index)
|
||||
{
|
||||
if (index < 0 || index >= ByteLength (array))
|
||||
throw new ArgumentOutOfRangeException ("index", Locale.GetText(
|
||||
"Value must be non-negative and less than the size of the collection."));
|
||||
|
||||
return GetByteInternal (array, index);
|
||||
}
|
||||
|
||||
public static void SetByte (Array array, int index, byte value)
|
||||
{
|
||||
if (index < 0 || index >= ByteLength (array))
|
||||
throw new ArgumentOutOfRangeException ("index", Locale.GetText(
|
||||
"Value must be non-negative and less than the size of the collection."));
|
||||
|
||||
SetByteInternal (array, index, value);
|
||||
}
|
||||
|
||||
public static void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count)
|
||||
{
|
||||
if (src == null)
|
||||
throw new ArgumentNullException ("src");
|
||||
|
||||
if (dst == null)
|
||||
throw new ArgumentNullException ("dst");
|
||||
|
||||
if (srcOffset < 0)
|
||||
throw new ArgumentOutOfRangeException ("srcOffset", Locale.GetText(
|
||||
"Non-negative number required."));
|
||||
|
||||
if (dstOffset < 0)
|
||||
throw new ArgumentOutOfRangeException ("dstOffset", Locale.GetText (
|
||||
"Non-negative number required."));
|
||||
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException ("count", Locale.GetText (
|
||||
"Non-negative number required."));
|
||||
|
||||
// We do the checks in unmanaged code for performance reasons
|
||||
bool res = BlockCopyInternal (src, srcOffset, dst, dstOffset, count);
|
||||
if (!res) {
|
||||
// watch for integer overflow
|
||||
if ((srcOffset > ByteLength (src) - count) || (dstOffset > ByteLength (dst) - count))
|
||||
throw new ArgumentException (Locale.GetText (
|
||||
"Offset and length were out of bounds for the array or count is greater than " +
|
||||
"the number of elements from index to the end of the source collection."));
|
||||
}
|
||||
}
|
||||
|
||||
// private
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern static int ByteLengthInternal (Array array);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern static byte GetByteInternal (Array array, int index);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private extern static void SetByteInternal (Array array, int index, int value);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal extern static bool BlockCopyInternal (Array src, int src_offset, Array dest, int dest_offset, int count);
|
||||
|
||||
internal static bool InternalBlockCopy (Array src, int src_offset, Array dest, int dest_offset, int count)
|
||||
{
|
||||
return BlockCopyInternal (src, src_offset, dest, dest_offset, count);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user