Beispiel #1
0
        /// <summary>
        ///     This method calculates the attach rules defined on
        ///     this dependency property.  It always returns a valid
        ///     AttachInfo, but the fields in AttachInfo may be null.
        /// </summary>
        internal static AttachInfo GetAttachInfo(DependencyProperty dp)
        {
            // Have we already seen this DP?
            AttachInfo info = (AttachInfo)_attachInfoMap[dp];

            if (info == null)
            {
                info = new AttachInfo(dp);

                lock (_attachInfoMap)
                {
                    _attachInfoMap[dp] = info;
                }
            }

            return(info);
        }
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        /// <summary>
        ///     This method determines if the given property can be attached
        ///     to the given instance.
        /// </summary>
        private bool CanAttachProperty(DependencyProperty dp, DependencyObject instance)
        {
            AttachInfo info = DependencyObjectProvider.GetAttachInfo(dp);

            return(info.CanAttach(instance));
        }
        /// <summary>
        ///     This method calculates the attach rules defined on 
        ///     this dependency property.  It always returns a valid
        ///     AttachInfo, but the fields in AttachInfo may be null.
        /// </summary>
        internal static AttachInfo GetAttachInfo(DependencyProperty dp)
        {
            // Have we already seen this DP?
            AttachInfo info = (AttachInfo)_attachInfoMap[dp];

            if (info == null) 
            {
                info = new AttachInfo(dp);
    
                lock(_attachInfoMap)
                {
                    _attachInfoMap[dp] = info;
                }
            }

            return info;
        }