singrdk/base/Applications/Runtime/Full/System/ObjectDisposedException.cs

57 lines
2.1 KiB
C#
Raw Permalink Normal View History

2008-03-05 09:52:00 -05:00
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
2008-11-17 18:29:00 -05:00
namespace System
{
2008-03-05 09:52:00 -05:00
using System;
//| <include path='docs/doc[@for="ObjectDisposedException"]/*' />
/// <devdoc>
/// <para> The exception that is thrown when accessing an object that was
/// disposed.</para>
/// </devdoc>
public class ObjectDisposedException : InvalidOperationException {
private String objectName;
//| <include path='docs/doc[@for="ObjectDisposedException.ObjectDisposedException"]/*' />
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ObjectDisposedException'/> class.</para>
/// </devdoc>
public ObjectDisposedException(String objectName) : base(String.Format("ObjectDisposed_Generic_ObjectName", objectName)) {
this.objectName = objectName;
}
//| <include path='docs/doc[@for="ObjectDisposedException.ObjectDisposedException2"]/*' />
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ObjectDisposedException'/> class.</para>
/// </devdoc>
public ObjectDisposedException(String objectName, String message) : base(message) {
this.objectName = objectName;
}
//| <include path='docs/doc[@for="ObjectDisposedException.Message"]/*' />
/// <devdoc>
/// <para>Gets the text for the message for this exception.</para>
/// </devdoc>
public override String Message {
get {
String name = ObjectName;
if (name == null || name.Length == 0)
return base.Message;
return base.Message + Environment.NewLine + String.Format("ObjectDisposed_ObjectName_Name", name);
}
}
//| <include path='docs/doc[@for="ObjectDisposedException.ObjectName"]/*' />
public String ObjectName {
get {
if (objectName == null)
return String.Empty;
return objectName;
}
}
}
}