//--------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner Microsoft // @backupOwner Microsoft //--------------------------------------------------------------------- namespace System.Data { using System; using System.Data; using System.Runtime.Serialization; using System.Security; using System.Security.Permissions; using System.Collections.Generic; using System.Collections.ObjectModel; /// /// Property constraint exception class. Note that this class has state - so if you change even /// its internals, it can be a breaking change /// /// [Serializable] public sealed class PropertyConstraintException : ConstraintException { private string _propertyName; /// /// constructor with default message /// public PropertyConstraintException() // required ctor : base() { } /// /// costructor with supplied message /// /// localized error message public PropertyConstraintException(string message) // required ctor : base(message) { } /// /// costructor with supplied message and inner exception /// /// localized error message /// inner exception public PropertyConstraintException(string message, Exception innerException) // required ctor : base(message, innerException) { } /// /// default constructor /// /// localized error message public PropertyConstraintException(string message, string propertyName) // required ctor : base(message) { EntityUtil.CheckStringArgument(propertyName, "propertyName"); _propertyName = propertyName; } /// /// constructor /// /// localized error message /// inner exception public PropertyConstraintException(string message, string propertyName, Exception innerException) // required ctor : base(message, innerException) { EntityUtil.CheckStringArgument(propertyName, "propertyName"); _propertyName = propertyName; } /// /// constructor for deserialization /// /// /// private PropertyConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info != null) { _propertyName = info.GetString("PropertyName"); } } /// /// sets the System.Runtime.Serialization.SerializationInfo /// with information about the exception. /// /// The System.Runtime.Serialization.SerializationInfo that holds the serialized /// object data about the exception being thrown. /// /// [SecurityCritical] [PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("PropertyName", _propertyName); } /// /// Gets the name of the property that violated the constraint. /// public string PropertyName { get { return _propertyName; } } } }