// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System
{
using System;
//|
///
/// The exception that is thrown when accessing an object that was
/// disposed.
///
public class ObjectDisposedException : InvalidOperationException {
private String objectName;
//|
///
/// Initializes a new instance of the class.
///
public ObjectDisposedException(String objectName) : base(String.Format("ObjectDisposed_Generic_ObjectName", objectName)) {
this.objectName = objectName;
}
//|
///
/// Initializes a new instance of the class.
///
public ObjectDisposedException(String objectName, String message) : base(message) {
this.objectName = objectName;
}
//|
///
/// Gets the text for the message for this exception.
///
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);
}
}
//|
public String ObjectName {
get {
if (objectName == null)
return String.Empty;
return objectName;
}
}
}
}