当前位置: 首页>>代码示例>>C#>>正文


C# DependencyObject.VerifyAccess方法代码示例

本文整理汇总了C#中System.Windows.DependencyObject.VerifyAccess方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.VerifyAccess方法的具体用法?C# DependencyObject.VerifyAccess怎么用?C# DependencyObject.VerifyAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.DependencyObject的用法示例。


在下文中一共展示了DependencyObject.VerifyAccess方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValueSource

        /// <summary>
        /// Return the source of the value for the given property.
        /// </summary>
        public static ValueSource GetValueSource(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException("dependencyObject");
            if (dependencyProperty == null)
                throw new ArgumentNullException("dependencyProperty");

            dependencyObject.VerifyAccess();

            bool hasModifiers, isExpression, isAnimated, isCoerced, isCurrent;
            BaseValueSourceInternal source = dependencyObject.GetValueSource(dependencyProperty, null, out hasModifiers, out isExpression, out isAnimated, out isCoerced, out isCurrent);

            return new ValueSource(source, isExpression, isAnimated, isCoerced, isCurrent);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:17,代码来源:DependencyPropertyHelper.cs

示例2: ChangeLogicalParent

 internal void ChangeLogicalParent(DependencyObject newParent)
 {
     this.VerifyAccess();
       if (newParent != null)
     newParent.VerifyAccess();
       if (this._parent != null && newParent != null && this._parent != newParent)
     throw new InvalidOperationException(System.Windows.SR.Get("HasLogicalParent"));
       if (newParent == this)
     throw new InvalidOperationException(System.Windows.SR.Get("CannotBeSelfParent"));
       if (newParent != null)
     this.ClearInheritanceContext();
       this.IsParentAnFE = newParent is FrameworkElement;
       DependencyObject oldParent = this._parent;
       this.OnNewParent(newParent);
       BroadcastEventHelper.AddOrRemoveHasLoadedChangeHandlerFlag((DependencyObject) this, oldParent, newParent);
       TreeWalkHelper.InvalidateOnTreeChange(this, (FrameworkContentElement) null, newParent != null ? newParent : oldParent, newParent != null);
       this.TryFireInitialized();
 }
开发者ID:jchristian,项目名称:ui_events,代码行数:18,代码来源:FrameworkElement.cs

示例3: Attach

        //------------------------------------------------------
        //
        //  Internal Methods 
        //
        //----------------------------------------------------- 
 
        /// <summary>
        /// Attach the binding expression to the given target object and property. 
        /// </summary>
        internal void Attach(DependencyObject target, DependencyProperty dp)
        {
            // make sure we're on the right thread to access the target 
            if (target != null)
            { 
                target.VerifyAccess(); 
            }
 
            IsAttaching = true;
            AttachOverride(target, dp);
            IsAttaching = false;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:21,代码来源:BindingExpressionBase.cs

示例4: AsVisual

        /// <summary> 
        ///     Returns null if the given element is null, otherwise visual or visual3D
        ///     will be the strong visual type on exit. 
        /// 
        ///     Throws an exception if element is a non-Visual type.
        /// </summary> 
        internal static void AsVisual(DependencyObject element, out Visual visual, out Visual3D visual3D)
        {
            bool castSucceeded = AsVisualHelper(element, out visual, out visual3D);
 
            if (element != null)
            { 
                if (!castSucceeded) 
                {
                    throw new System.InvalidOperationException(SR.Get(SRID.Visual_NotAVisual, element.GetType())); 
                }

                Debug.Assert(castSucceeded && ((visual == null) != (visual3D == null)),
                    "Either visual or visual3D exclusively should be non-null."); 

                element.VerifyAccess(); 
            } 
            else
            { 
                Debug.Assert(!castSucceeded && visual == null && visual3D == null,
                    "How did the cast succeed if the element was null going in?");
            }
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:28,代码来源:VisualTreeUtils.cs

示例5: EnsureVisual

        /// <summary> 
        ///     Throws if the given element is not a Visual or Visual3D
        ///     or if the Visual is on the wrong thread. 
        /// </summary>
        private static void EnsureVisual(DependencyObject element, bool allowNull)
        {
            if (element == null) 
            {
                if (!allowNull) 
                { 
                    throw new ArgumentNullException("element");
                } 

                return;
            }
 
            //
            if (!(element is Visual || element is Visual3D)) 
            { 
                throw new ArgumentException(SR.Get(SRID.Visual_NotAVisual));
            } 

            element.VerifyAccess();
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:24,代码来源:VisualTreeUtils.cs

示例6: ChangeLogicalParent

        /// <summary>
        ///     Invoked when logical parent is changed.  This just
        ///     sets the parent pointer.
        /// </summary>
        /// <remarks>
        ///     A parent change is considered catastrohpic and results in a large
        ///     amount of invalidations and tree traversals. <cref see="DependencyFastBuild"/>
        ///     is recommended to reduce the work necessary to build a tree
        /// </remarks>
        /// <param name="newParent">
        ///     New parent that was set
        /// </param>
        internal void ChangeLogicalParent(DependencyObject newParent)
        {
            ///////////////////
            // OnNewParent:
            ///////////////////

            //
            // -- Approved By The Core Team --
            //
            // Do not allow foreign threads to change the tree.
            // (This is a noop if this object is not assigned to a Dispatcher.)
            //
            // We also need to ensure that the tree is homogenous with respect
            // to the dispatchers that the elements belong to.
            //
            this.VerifyAccess();
            if(newParent != null)
            {
                newParent.VerifyAccess();
            }

            // Logical Parent must first be dropped before you are attached to a newParent
            // This mitigates illegal tree state caused by logical child stealing as illustrated in bug 970706
            if (_parent != null && newParent != null && _parent != newParent)
            {
                throw new System.InvalidOperationException(SR.Get(SRID.HasLogicalParent));
            }

            // Trivial check to avoid loops
            if (newParent == this)
            {
                throw new System.InvalidOperationException(SR.Get(SRID.CannotBeSelfParent));
            }

            // Logical Parent implies no InheritanceContext
            if (newParent != null)
            {
                ClearInheritanceContext();
            }

            IsParentAnFE = newParent is FrameworkElement;

            DependencyObject oldParent = _parent;
            OnNewParent(newParent);

            // Update Has[Loaded/Unloaded]Handler Flags
            BroadcastEventHelper.AddOrRemoveHasLoadedChangeHandlerFlag(this, oldParent, newParent);


            // Fire Loaded and Unloaded Events
            BroadcastEventHelper.BroadcastLoadedOrUnloadedEvent(this, oldParent, newParent);


            ///////////////////
            // OnParentChanged:
            ///////////////////

            // Invalidate relevant properties for this subtree
            DependencyObject parent = (newParent != null) ? newParent : oldParent;
            TreeWalkHelper.InvalidateOnTreeChange(/* fe = */ null, /* fce = */ this, parent, (newParent != null));

            // If no one has called BeginInit then mark the element initialized and fire Initialized event
            // (non-parser programmatic tree building scenario)
            TryFireInitialized();
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:77,代码来源:FrameworkContentElement.cs


注:本文中的System.Windows.DependencyObject.VerifyAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。