コード例 #1
0
 internal void OnDeferredResourceInflated(DeferredResourceReference deferredResourceReference)
 {
     if (this.ReadInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated))
     {
         deferredResourceReference.RemoveInflatedListener(this);
         this.WriteInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated, false);
     }
     this.ListenForFreezableChanges(deferredResourceReference.Value);
 }
コード例 #2
0
        internal object GetRawValue(DependencyObject d, out object source, DependencyProperty dp)
        {
            Appercode.UI.Controls.UIElement frameworkElement = null;
            object unsetValue = null;

            source = null;
            if (!this.ReadInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid))
            {
                ////this.mentorCache = Helper.FindMentor(d);
                this.WriteInternalState(ResourceReferenceExpression.InternalState.IsMentorCacheValid, true);
                if (this.mentorCache != null && this.mentorCache != this.targetObject)
                {
                    ////Helper.DowncastToFEorFCE(this.mentorCache, out frameworkElement, out frameworkContentElement, true);
                    if (frameworkElement != null)
                    {
                        frameworkElement.ResourcesChanged += new EventHandler(this.InvalidateExpressionValue);
                    }
                }
            }

            /*
             * if (this.mentorCache == null)
             * {
             *  //unsetValue = Helper.FindResourceFromAppOrSystem(this.resourceKey, out source, false, true, false) ?? DependencyProperty.UnsetValue;
             * }
             * else
             * {
             *  //Helper.DowncastToFEorFCE(this.mentorCache, out frameworkElement1, out frameworkContentElement1, true);
             *  //unsetValue = UIElement.FindResourceInternal(frameworkElement1, frameworkContentElement1, dp, this.resourceKey, null, true, false, null, false, out source);
             * }
             */

            if (unsetValue == null)
            {
                unsetValue = DependencyProperty.UnsetValue;
            }
            this.cachedResourceValue = unsetValue;
            this.WriteInternalState(ResourceReferenceExpression.InternalState.HasCachedResourceValue, true);
            object value = unsetValue;
            DeferredResourceReference deferredResourceReference = unsetValue as DeferredResourceReference;

            if (deferredResourceReference != null)
            {
                if (deferredResourceReference.IsInflated)
                {
                    value = deferredResourceReference.Value as Freezable;
                }
                else if (!this.ReadInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated))
                {
                    deferredResourceReference.AddInflatedListener(this);
                    this.WriteInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated, true);
                }
            }
            this.ListenForFreezableChanges(value);
            return(unsetValue);
        }
コード例 #3
0
        private void InvalidateCacheValue()
        {
            object value = this.cachedResourceValue;
            DeferredResourceReference deferredResourceReference = this.cachedResourceValue as DeferredResourceReference;

            if (deferredResourceReference != null)
            {
                if (deferredResourceReference.IsInflated)
                {
                    value = deferredResourceReference.Value;
                }
                else if (this.ReadInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated))
                {
                    deferredResourceReference.RemoveInflatedListener(this);
                    this.WriteInternalState(ResourceReferenceExpression.InternalState.IsListeningForInflated, false);
                }
                deferredResourceReference.RemoveFromDictionary();
            }
            this.StopListeningForFreezableChanges(value);
            this.cachedResourceValue = null;
            this.WriteInternalState(ResourceReferenceExpression.InternalState.HasCachedResourceValue, false);
        }