File: src\Framework\System\Windows\SetterBase.cs
Project: wpf\PresentationFramework.csproj (PresentationFramework)
/***************************************************************************\
*
* File: SetterBase.cs
*
*  TargetType property and event setting base class.
*
* Copyright (C) 2004 by Microsoft Corporation.  All rights reserved.
*
\***************************************************************************/
 
namespace System.Windows
{
    /// <summary>
    ///     TargetType property and event setting base class.
    /// </summary>
    [Localizability(LocalizationCategory.Ignore)]
    public abstract class SetterBase
    {
        /// <summary>
        ///     SetterBase construction
        /// </summary>
        internal SetterBase()
        {
        }
 
        /// <summary>
        ///     Returns the sealed state of this object.  If true, any attempt
        /// at modifying the state of this object will trigger an exception.
        /// </summary>
        public bool IsSealed
        {
            get
            {
                return _sealed;
            }
        }
 
        internal virtual void Seal()
        {
            _sealed = true;
        }
 
        /// <summary>
        ///  Subclasses need to call this method before any changes to their state.
        /// </summary>
        protected void CheckSealed()
        {
            if ( _sealed )
            {
                throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SetterBase"));
            }            
        }
 
        // Derived
        private bool _sealed;
    }
        
}