Example #1
0
        // returns the parent in the "prefer-visual" sense.
        // That is, this method
        //  1. prefers visual to logical parent (with InheritanceContext last)
        //  2. does not see parents whose InheritanceBehavior forbids it
        // Call with force=true to get the parent even if the current object doesn't
        // allow it via rule 2.
        internal FrameworkObject GetPreferVisualParent(bool force)
        {
            // If we're not allowed to move up from here, return null
            InheritanceBehavior inheritanceBehavior = force ? InheritanceBehavior.Default : this.InheritanceBehavior;

            if (inheritanceBehavior != InheritanceBehavior.Default)
            {
                return(new FrameworkObject(null));
            }

            FrameworkObject parent = GetRawPreferVisualParent();

            // make sure the parent allows itself to be found
            switch (parent.InheritanceBehavior)
            {
            case InheritanceBehavior.SkipToAppNow:
            case InheritanceBehavior.SkipToThemeNow:
            case InheritanceBehavior.SkipAllNow:
                parent.Reset(null);
                break;

            default:
                break;
            }

            return(parent);
        }
Example #2
0
 public FieldDefinition(
     DataFieldAttribute attr,
     object?defaultValue,
     AbstractFieldInfo fieldInfo,
     AbstractFieldInfo backingField,
     InheritanceBehavior inheritanceBehavior)
 {
     BackingField        = backingField;
     Attribute           = attr;
     DefaultValue        = defaultValue;
     FieldInfo           = fieldInfo;
     InheritanceBehavior = inheritanceBehavior;
 }
        // Token: 0x060064A6 RID: 25766 RVA: 0x001C3B9C File Offset: 0x001C1D9C
        internal FrameworkObject GetPreferVisualParent(bool force)
        {
            InheritanceBehavior inheritanceBehavior = force ? InheritanceBehavior.Default : this.InheritanceBehavior;

            if (inheritanceBehavior != InheritanceBehavior.Default)
            {
                return(new FrameworkObject(null));
            }
            FrameworkObject rawPreferVisualParent = this.GetRawPreferVisualParent();

            switch (rawPreferVisualParent.InheritanceBehavior)
            {
            case InheritanceBehavior.SkipToAppNow:
            case InheritanceBehavior.SkipToThemeNow:
            case InheritanceBehavior.SkipAllNow:
                rawPreferVisualParent.Reset(null);
                break;
            }
            return(rawPreferVisualParent);
        }
Example #4
0
 // Token: 0x06000C73 RID: 3187 RVA: 0x0002EE02 File Offset: 0x0002D002
 internal static bool SkipNext(InheritanceBehavior inheritanceBehavior)
 {
     return(inheritanceBehavior == InheritanceBehavior.SkipToAppNext || inheritanceBehavior == InheritanceBehavior.SkipToThemeNext || inheritanceBehavior == InheritanceBehavior.SkipAllNext);
 }
Example #5
0
 // Token: 0x06000C72 RID: 3186 RVA: 0x0002EDF1 File Offset: 0x0002CFF1
 internal static bool SkipNow(InheritanceBehavior inheritanceBehavior)
 {
     return(inheritanceBehavior == InheritanceBehavior.SkipToAppNow || inheritanceBehavior == InheritanceBehavior.SkipToThemeNow || inheritanceBehavior == InheritanceBehavior.SkipAllNow);
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassCleanupAttribute"/> class.
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassCleanup Inheritance Behavior
 /// </param>
 /// <param name="cleanupBehavior">
 /// Specifies the class clean-up behavior.
 /// To capture output of class clean-up method in logs
 /// <paramref name="cleanupBehavior"/> must be set to <see cref="ClassCleanupBehavior.EndOfClass"/>.
 /// </param>
 public ClassCleanupAttribute(InheritanceBehavior inheritanceBehavior, ClassCleanupBehavior cleanupBehavior)
     : this(inheritanceBehavior, new ClassCleanupBehavior?(cleanupBehavior))
 {
 }
Example #7
0
 public DeserializedFieldEntry(bool mapped, InheritanceBehavior inheritanceBehavior, DeserializationResult?result = null)
 {
     Mapped = mapped;
     Result = result;
     InheritanceBehavior = inheritanceBehavior;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassInitializeAttribute"/> class.
 /// ClassInitializeAttribute
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassInitialize Inheritance Behavior
 /// </param>
 public ClassInitializeAttribute(InheritanceBehavior inheritanceBehavior)
 {
     this.InheritanceBehavior = inheritanceBehavior;
 }
Example #9
0
        /// <summary> 
        ///     Says if the given value has SkipNext behavior
        /// </summary> 
        internal static bool SkipNext(InheritanceBehavior inheritanceBehavior) 
        {
            if (inheritanceBehavior == InheritanceBehavior.SkipToAppNext || 
                inheritanceBehavior == InheritanceBehavior.SkipToThemeNext ||
                inheritanceBehavior == InheritanceBehavior.SkipAllNext)
            {
                return true; 
            }
 
            return false; 
        }
Example #10
0
        /// <summary> 
        ///     Determine if the current DependencyObject is a candidate for 
        ///     producing inheritable values
        /// </summary> 
        /// <remarks>
        ///     This is called by both InvalidateTree and GetValueCore
        /// </remarks>
        internal static bool IsInheritanceNode( 
            DependencyObject    d,
            DependencyProperty  dp, 
        out InheritanceBehavior inheritanceBehavior) 
        {
            // Assume can continue search 
            inheritanceBehavior = InheritanceBehavior.Default;

            // Get Framework metadata (if exists)
            FrameworkPropertyMetadata metadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata; 

            // Check for correct type of metadata 
            if (metadata != null) 
            {
                FrameworkObject fo = new FrameworkObject(d); 

                if (fo.IsValid)
                {
                    // If parent is a Framework type, then check if it is at a 
                    // tree separation boundary. Stop inheritance at the boundary unless
                    // overridden by the medata.OverridesInheritanceBehavior flag. 
 
                    // GetValue from Parent only if instance is not a TreeSeparator
                    // or fmetadata.OverridesInheritanceBehavior is set to override separated tree behavior 
                    if (fo.InheritanceBehavior != InheritanceBehavior.Default && !metadata.OverridesInheritanceBehavior)
                    {
                        // Hit a tree boundary
                        inheritanceBehavior = fo.InheritanceBehavior; 
                    }
                } 
                else 
                {
                    // If not a Framework type, then, this isn't an inheritance node. 
                    // Only Framework types know how to inherit

                    return false;
                } 

                // Check if metadata is marked as inheritable 
                if (metadata.Inherits) 
                {
                    return true; 
                }
            }

            // Not a framework type with inheritable metadata 
            return false;
        } 
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassInitializeAttribute"/> class.
 /// ClassInitializeAttribute.
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassInitialize Inheritance Behavior.
 /// </param>
 public ClassInitializeAttribute(InheritanceBehavior inheritanceBehavior)
 {
     this.InheritanceBehavior = inheritanceBehavior;
     this.Scope = TestCycleScope.Class;
 }
Example #12
0
        // FindResourceInTree(fe/fce)  Defaults: none
        internal static object FindResourceInTree( 
            FrameworkElement        feStart,
            FrameworkContentElement fceStart,
            DependencyProperty      dp,
            object                  resourceKey, 
            object                  unlinkedParent,
            bool                    allowDeferredResourceReference, 
            bool                    mustReturnDeferredResourceReference, 
            DependencyObject        boundaryElement,
            out InheritanceBehavior inheritanceBehavior, 
            out object              source)
        {
            FrameworkObject startNode = new FrameworkObject(feStart, fceStart);
            FrameworkObject fo = startNode; 
            object value;
            Style style; 
            FrameworkTemplate frameworkTemplate; 
            Style themeStyle;
            int loopCount = 0; 
            bool hasParent = true;
            inheritanceBehavior = InheritanceBehavior.Default;

            while (hasParent) 
            {
                Debug.Assert(startNode.IsValid || unlinkedParent != null, 
                              "Don't call FindResource with a null fe/fce and unlinkedParent"); 

                if (loopCount > ContextLayoutManager.s_LayoutRecursionLimit) 
                {
                    // We suspect a loop here because the loop count
                    // has exceeded the MAX_TREE_DEPTH expected
                    throw new InvalidOperationException(SR.Get(SRID.LogicalTreeLoop)); 
                }
                else 
                { 
                    loopCount++;
                } 

                // -------------------------------------------
                //  Lookup ResourceDictionary on the current instance
                // ------------------------------------------- 

                style = null; 
                frameworkTemplate = null; 
                themeStyle = null;
 
                if (fo.IsFE)
                {
                    FrameworkElement fe = fo.FE;
 
                    value = fe.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
                    if (value != DependencyProperty.UnsetValue) 
                    { 
                        source = fe;
 
                        if( TraceResourceDictionary.IsEnabled )
                        {
                            TraceResourceDictionary.TraceActivityItem(
                                TraceResourceDictionary.FoundResourceOnElement, 
                                source,
                                resourceKey, 
                                value ); 
                        }
 
                        return value;
                    }

                    if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromStyle(dp)) 
                    {
                        style = fe.Style; 
                    } 
                    // Fetch the Template
                    if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromTemplate(dp)) 
                    {
                        frameworkTemplate = fe.TemplateInternal;
                    }
                    // Fetch the ThemeStyle 
                    if ((fe != startNode.FE) || StyleHelper.ShouldGetValueFromThemeStyle(dp))
                    { 
                        themeStyle = fe.ThemeStyle; 
                    }
                } 
                else if (fo.IsFCE)
                {
                    FrameworkContentElement fce = fo.FCE;
 
                    value = fce.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
                    if (value != DependencyProperty.UnsetValue) 
                    { 
                        source = fce;
 
                        if( TraceResourceDictionary.IsEnabled )
                        {
                            TraceResourceDictionary.TraceActivityItem(
                                TraceResourceDictionary.FoundResourceOnElement, 
                                source,
                                resourceKey, 
                                value ); 
                        }
 
                        return value;
                    }

                    if ((fce != startNode.FCE) || StyleHelper.ShouldGetValueFromStyle(dp)) 
                    {
                        style = fce.Style; 
                    } 
                    // Fetch the ThemeStyle
                    if ((fce != startNode.FCE) || StyleHelper.ShouldGetValueFromThemeStyle(dp)) 
                    {
                        themeStyle = fce.ThemeStyle;
                    }
                } 

                if (style != null) 
                { 
                    value = style.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
                    if (value != DependencyProperty.UnsetValue) 
                    {
                        source = style;

                        if( TraceResourceDictionary.IsEnabled ) 
                        {
                            TraceResourceDictionary.TraceActivityItem( 
                                TraceResourceDictionary.FoundResourceInStyle, 
                                style.Resources,
                                resourceKey, 
                                style,
                                fo.DO,
                                value );
                        } 

                        return value; 
                    } 
                }
                if (frameworkTemplate != null) 
                {
                    value = frameworkTemplate.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
                    if (value != DependencyProperty.UnsetValue)
                    { 
                        source = frameworkTemplate;
 
                        if( TraceResourceDictionary.IsEnabled ) 
                        {
                            TraceResourceDictionary.TraceActivityItem( 
                                TraceResourceDictionary.FoundResourceInTemplate,
                                frameworkTemplate.Resources,
                                resourceKey,
                                frameworkTemplate, 
                                fo.DO,
                                value ); 
                        } 

                        return value; 
                    }
                }

                if (themeStyle != null) 
                {
                    value = themeStyle.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference); 
                    if (value != DependencyProperty.UnsetValue) 
                    {
                        source = themeStyle; 

                        if( TraceResourceDictionary.IsEnabled )
                        {
                            TraceResourceDictionary.TraceActivityItem( 
                                TraceResourceDictionary.FoundResourceInThemeStyle,
                                themeStyle.Resources, 
                                resourceKey, 
                                themeStyle,
                                fo.DO, 
                                value );
                        }

                        return value; 
                    }
                } 
 

                // If the current element that has been searched is the boundary element 
                // then we need to progress no further
                if (boundaryElement != null && (fo.DO == boundaryElement))
                {
                    break; 
                }
 
                // If the current element for resource lookup is marked such 
                // then skip to the Application and/or System resources
                if (fo.IsValid && TreeWalkHelper.SkipNext(fo.InheritanceBehavior)) 
                {
                    inheritanceBehavior = fo.InheritanceBehavior;
                    break;
                } 

                // ------------------------------------------- 
                //  Find the next parent instance to lookup 
                // -------------------------------------------
 
                if (unlinkedParent != null)
                {
                    // This is for the special case when the parser tries to fetch
                    // a resource on an element even before it is hooked to the 
                    // tree. In this case the parser passes us the unlinkedParent
                    // to use it for resource lookup. 
                    DependencyObject unlinkedParentAsDO = unlinkedParent as DependencyObject; 
                    if (unlinkedParentAsDO != null)
                    { 
                        fo.Reset(unlinkedParentAsDO);
                        if (fo.IsValid)
                        {
                            hasParent = true; 
                        }
                        else 
                        { 
                            DependencyObject doParent = GetFrameworkParent(unlinkedParent);
                            if (doParent != null) 
                            {
                                fo.Reset(doParent);
                                hasParent = true;
                            } 
                            else
                            { 
                                hasParent = false; 
                            }
                        } 
                    }
                    else
                    {
                        hasParent = false; 
                    }
                    unlinkedParent = null; 
                } 
                else
                { 
                    Debug.Assert(fo.IsValid,
                                  "The current node being processed should be an FE/FCE");

                    fo = fo.FrameworkParent; 

                    hasParent = fo.IsValid; 
                } 

                // If the current element for resource lookup is marked such 
                // then skip to the Application and/or System resources
                if (fo.IsValid && TreeWalkHelper.SkipNow(fo.InheritanceBehavior))
                {
                    inheritanceBehavior = fo.InheritanceBehavior; 
                    break;
                } 
            } 

            // No matching resource was found in the tree 
            source = null;
            return DependencyProperty.UnsetValue;
        }
Example #13
0
 internal static object FindResourceInTree(FrameworkElement feStart, FrameworkContentElement fceStart, DependencyProperty dp, object resourceKey, object unlinkedParent, bool allowDeferredResourceReference, bool mustReturnDeferredResourceReference, DependencyObject boundaryElement, out InheritanceBehavior inheritanceBehavior, out object source)
 {
     FrameworkObject frameworkObject1 = new FrameworkObject(feStart, fceStart);
       FrameworkObject frameworkObject2 = frameworkObject1;
       int num = 0;
       bool flag = true;
       inheritanceBehavior = InheritanceBehavior.Default;
       while (flag)
       {
     if (num > ContextLayoutManager.s_LayoutRecursionLimit)
       throw new InvalidOperationException(System.Windows.SR.Get("LogicalTreeLoop"));
     ++num;
     Style style1 = (Style) null;
     FrameworkTemplate frameworkTemplate = (FrameworkTemplate) null;
     Style style2 = (Style) null;
     if (frameworkObject2.IsFE)
     {
       FrameworkElement fe = frameworkObject2.FE;
       object resourceOnSelf = fe.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
       if (resourceOnSelf != DependencyProperty.UnsetValue)
       {
     source = (object) fe;
     if (TraceResourceDictionary.IsEnabled)
       TraceResourceDictionary.TraceActivityItem(TraceResourceDictionary.FoundResourceOnElement, source, resourceKey, resourceOnSelf);
     return resourceOnSelf;
       }
       else
       {
     if (fe != frameworkObject1.FE || StyleHelper.ShouldGetValueFromStyle(dp))
       style1 = fe.Style;
     if (fe != frameworkObject1.FE || StyleHelper.ShouldGetValueFromTemplate(dp))
       frameworkTemplate = fe.TemplateInternal;
     if (fe != frameworkObject1.FE || StyleHelper.ShouldGetValueFromThemeStyle(dp))
       style2 = fe.ThemeStyle;
       }
     }
     else if (frameworkObject2.IsFCE)
     {
       FrameworkContentElement fce = frameworkObject2.FCE;
       object resourceOnSelf = fce.FindResourceOnSelf(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
       if (resourceOnSelf != DependencyProperty.UnsetValue)
       {
     source = (object) fce;
     if (TraceResourceDictionary.IsEnabled)
       TraceResourceDictionary.TraceActivityItem(TraceResourceDictionary.FoundResourceOnElement, source, resourceKey, resourceOnSelf);
     return resourceOnSelf;
       }
       else
       {
     if (fce != frameworkObject1.FCE || StyleHelper.ShouldGetValueFromStyle(dp))
       style1 = fce.Style;
     if (fce != frameworkObject1.FCE || StyleHelper.ShouldGetValueFromThemeStyle(dp))
       style2 = fce.ThemeStyle;
       }
     }
     if (style1 != null)
     {
       object resource = style1.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
       if (resource != DependencyProperty.UnsetValue)
       {
     source = (object) style1;
     if (TraceResourceDictionary.IsEnabled)
       TraceResourceDictionary.TraceActivityItem(TraceResourceDictionary.FoundResourceInStyle, (object) style1.Resources, resourceKey, (object) style1, (object) frameworkObject2.DO, resource);
     return resource;
       }
     }
     if (frameworkTemplate != null)
     {
       object resource = frameworkTemplate.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
       if (resource != DependencyProperty.UnsetValue)
       {
     source = (object) frameworkTemplate;
     if (TraceResourceDictionary.IsEnabled)
       TraceResourceDictionary.TraceActivityItem(TraceResourceDictionary.FoundResourceInTemplate, (object) frameworkTemplate.Resources, resourceKey, (object) frameworkTemplate, (object) frameworkObject2.DO, resource);
     return resource;
       }
     }
     if (style2 != null)
     {
       object resource = style2.FindResource(resourceKey, allowDeferredResourceReference, mustReturnDeferredResourceReference);
       if (resource != DependencyProperty.UnsetValue)
       {
     source = (object) style2;
     if (TraceResourceDictionary.IsEnabled)
       TraceResourceDictionary.TraceActivityItem(TraceResourceDictionary.FoundResourceInThemeStyle, (object) style2.Resources, resourceKey, (object) style2, (object) frameworkObject2.DO, resource);
     return resource;
       }
     }
     if (boundaryElement == null || frameworkObject2.DO != boundaryElement)
     {
       if (frameworkObject2.IsValid && TreeWalkHelper.SkipNext(frameworkObject2.InheritanceBehavior))
       {
     inheritanceBehavior = frameworkObject2.InheritanceBehavior;
     break;
       }
       else
       {
     if (unlinkedParent != null)
     {
       DependencyObject d = unlinkedParent as DependencyObject;
       if (d != null)
       {
         frameworkObject2.Reset(d);
         if (frameworkObject2.IsValid)
         {
           flag = true;
         }
         else
         {
           DependencyObject frameworkParent = FrameworkElement.GetFrameworkParent(unlinkedParent);
           if (frameworkParent != null)
           {
             frameworkObject2.Reset(frameworkParent);
             flag = true;
           }
           else
             flag = false;
         }
       }
       else
         flag = false;
       unlinkedParent = (object) null;
     }
     else
     {
       frameworkObject2 = frameworkObject2.FrameworkParent;
       flag = frameworkObject2.IsValid;
     }
     if (frameworkObject2.IsValid && TreeWalkHelper.SkipNow(frameworkObject2.InheritanceBehavior))
     {
       inheritanceBehavior = frameworkObject2.InheritanceBehavior;
       break;
     }
       }
     }
     else
       break;
       }
       source = (object) null;
       return DependencyProperty.UnsetValue;
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassCleanupAttribute"/> class.
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassCleanup Inheritance Behavior
 /// </param>
 /// <param name="cleanupBehavior">
 /// Specifies the class clean-up behavior.
 /// To capture output of class clean-up method in logs
 /// <paramref name="cleanupBehavior"/> must be set to <see cref="ClassCleanupBehavior.EndOfClass"/>.
 /// </param>
 private ClassCleanupAttribute(InheritanceBehavior inheritanceBehavior, ClassCleanupBehavior?cleanupBehavior)
 {
     this.InheritanceBehavior = inheritanceBehavior;
     this.CleanupBehavior     = cleanupBehavior;
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassCleanupAttribute"/> class.
 /// ClassCleanupAttribute.
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassCleanup Inheritance Behavior.
 /// </param>
 public ClassCleanupAttribute(InheritanceBehavior inheritanceBehavior)
 {
     this.InheritanceBehavior = inheritanceBehavior;
     this.Scope = TestCycleScope.Class;
 }
Example #16
0
        // Invalidate all the properties that may have changed as a result of
        //  changing this element's parent in the logical (and sometimes visual tree.)
        internal FrugalObjectList <DependencyProperty> InvalidateTreeDependentProperties(TreeChangeInfo parentTreeState, bool isSelfInheritanceParent, bool wasSelfInheritanceParent)
        {
            AncestorChangeInProgress = true;


            try
            {
                // Style property is a special case of a non-inherited property that needs
                // invalidation for parent changes. Invalidate StyleProperty if it hasn't been
                // locally set because local value takes precedence over implicit references
                if (!HasLocalStyle && (this != parentTreeState.Root))
                {
                    UpdateStyleProperty();
                }

                Style            selfStyle       = null;
                Style            selfThemeStyle  = null;
                DependencyObject templatedParent = null;

                int         childIndex         = -1;
                ChildRecord childRecord        = new ChildRecord();
                bool        isChildRecordValid = false;

                selfStyle       = Style;
                selfThemeStyle  = ThemeStyle;
                templatedParent = TemplatedParent;
                childIndex      = TemplateChildIndex;

                // StyleProperty could have changed during invalidation of ResourceReferenceExpressions if it
                // were locally set or during the invalidation of unresolved implicitly referenced style
                bool hasStyleChanged = HasStyleChanged;

                // Fetch selfStyle, hasStyleChanged and childIndex for the current node
                FrameworkElement.GetTemplatedParentChildRecord(templatedParent, childIndex, out childRecord, out isChildRecordValid);

                FrameworkElement        parentFE;
                FrameworkContentElement parentFCE;
                bool hasParent = FrameworkElement.GetFrameworkParent(this, out parentFE, out parentFCE);

                DependencyObject    parent = null;
                InheritanceBehavior parentInheritanceBehavior = InheritanceBehavior.Default;
                if (hasParent)
                {
                    if (parentFE != null)
                    {
                        parent = parentFE;
                        parentInheritanceBehavior = parentFE.InheritanceBehavior;
                    }
                    else
                    {
                        parent = parentFCE;
                        parentInheritanceBehavior = parentFCE.InheritanceBehavior;
                    }
                }

                if (!TreeWalkHelper.SkipNext(InheritanceBehavior) && !TreeWalkHelper.SkipNow(parentInheritanceBehavior))
                {
                    // Synchronize InheritanceParent
                    this.SynchronizeInheritanceParent(parent);
                }
                else if (!IsSelfInheritanceParent)
                {
                    // Set IsSelfInheritanceParet on the root node at a tree boundary
                    // so that all inheritable properties are cached on it.
                    SetIsSelfInheritanceParent();
                }

                // Loop through all cached inheritable properties for the parent to see if they should be invalidated.
                return(TreeWalkHelper.InvalidateTreeDependentProperties(parentTreeState, /* fe = */ null, /* fce = */ this, selfStyle, selfThemeStyle,
                                                                        ref childRecord, isChildRecordValid, hasStyleChanged, isSelfInheritanceParent, wasSelfInheritanceParent));
            }
            finally
            {
                AncestorChangeInProgress = false;
            }
        }
Example #17
0
        // Token: 0x06000C6D RID: 3181 RVA: 0x0002EB78 File Offset: 0x0002CD78
        private static bool OnInheritablePropertyChanged(DependencyObject d, InheritablePropertyChangeInfo info, bool visitedViaVisualTree)
        {
            DependencyProperty  property = info.Property;
            EffectiveValueEntry oldEntry = info.OldEntry;
            EffectiveValueEntry newEntry = info.NewEntry;
            InheritanceBehavior inheritanceBehavior;
            bool flag  = TreeWalkHelper.IsInheritanceNode(d, property, out inheritanceBehavior);
            bool flag2 = TreeWalkHelper.IsForceInheritedProperty(property);

            if (!flag || (TreeWalkHelper.SkipNext(inheritanceBehavior) && !flag2))
            {
                return(inheritanceBehavior == InheritanceBehavior.Default || flag2);
            }
            PropertyMetadata metadata   = property.GetMetadata(d);
            EntryIndex       entryIndex = d.LookupEntry(property.GlobalIndex);

            if (!d.IsSelfInheritanceParent)
            {
                DependencyObject    frameworkParent      = FrameworkElement.GetFrameworkParent(d);
                InheritanceBehavior inheritanceBehavior2 = InheritanceBehavior.Default;
                if (frameworkParent != null)
                {
                    FrameworkObject frameworkObject = new FrameworkObject(frameworkParent, true);
                    inheritanceBehavior2 = frameworkObject.InheritanceBehavior;
                }
                if (!TreeWalkHelper.SkipNext(inheritanceBehavior) && !TreeWalkHelper.SkipNow(inheritanceBehavior2))
                {
                    d.SynchronizeInheritanceParent(frameworkParent);
                }
                if (oldEntry.BaseValueSourceInternal == BaseValueSourceInternal.Unknown)
                {
                    oldEntry = EffectiveValueEntry.CreateDefaultValueEntry(property, metadata.GetDefaultValue(d, property));
                }
            }
            else
            {
                oldEntry = d.GetValueEntry(entryIndex, property, metadata, RequestFlags.RawEntry);
            }
            if (BaseValueSourceInternal.Inherited >= oldEntry.BaseValueSourceInternal)
            {
                if (visitedViaVisualTree && FrameworkElement.DType.IsInstanceOfType(d))
                {
                    DependencyObject parent = LogicalTreeHelper.GetParent(d);
                    if (parent != null)
                    {
                        DependencyObject parent2 = VisualTreeHelper.GetParent(d);
                        if (parent2 != null && parent2 != parent)
                        {
                            return(false);
                        }
                    }
                }
                return((d.UpdateEffectiveValue(entryIndex, property, metadata, oldEntry, ref newEntry, false, false, OperationType.Inherit) & (UpdateResult)5) == UpdateResult.ValueChanged);
            }
            if (flag2)
            {
                newEntry = new EffectiveValueEntry(property, FullValueSource.IsCoerced);
                return((d.UpdateEffectiveValue(d.LookupEntry(property.GlobalIndex), property, metadata, oldEntry, ref newEntry, false, false, OperationType.Inherit) & (UpdateResult)5) == UpdateResult.ValueChanged);
            }
            return(false);
        }
Example #18
0
        /// <summary>
        ///     FrameworkContentElement variant of IsInheritanceNode 
        /// </summary>
        internal static bool IsInheritanceNode( 
            FrameworkContentElement fce, 
            DependencyProperty      dp,
            out InheritanceBehavior inheritanceBehavior) 
        {
            // Assume can continue search
            inheritanceBehavior = InheritanceBehavior.Default;
 
            // Get Framework metadata (if exists)
            FrameworkPropertyMetadata metadata = dp.GetMetadata(fce.DependencyObjectType) as FrameworkPropertyMetadata; 
 
            // Check for correct type of metadata
            if (metadata != null) 
            {
                if (fce.InheritanceBehavior != InheritanceBehavior.Default && !metadata.OverridesInheritanceBehavior)
                {
                    // Hit a tree boundary 
                    inheritanceBehavior = fce.InheritanceBehavior;
                } 
 
                // Return true if metadata is marked as inheritable; false otherwise
                return metadata.Inherits; 
            }

            // Not framework type metadata
            return false; 
        }
Example #19
0
 // Token: 0x06000C6E RID: 3182 RVA: 0x0002ECD4 File Offset: 0x0002CED4
 internal static void OnInheritedPropertyChanged(DependencyObject d, ref InheritablePropertyChangeInfo info, InheritanceBehavior inheritanceBehavior)
 {
     if (inheritanceBehavior == InheritanceBehavior.Default || TreeWalkHelper.IsForceInheritedProperty(info.Property))
     {
         FrameworkObject frameworkObject = new FrameworkObject(d);
         frameworkObject.OnInheritedPropertyChanged(ref info);
     }
 }
Example #20
0
 // raise the InheritedPropertyChanged event to mentees.  Called from FE/FCE
 // OnPropertyChanged
 internal static void OnInheritedPropertyChanged(DependencyObject d, 
                                     ref InheritablePropertyChangeInfo info,
                                     InheritanceBehavior inheritanceBehavior) 
 { 
     if (inheritanceBehavior == InheritanceBehavior.Default || IsForceInheritedProperty(info.Property))
     { 
         FrameworkObject fo = new FrameworkObject(d);
         fo.OnInheritedPropertyChanged(ref info);
     }
 } 
Example #21
0
        // Token: 0x06000C6F RID: 3183 RVA: 0x0002ED04 File Offset: 0x0002CF04
        internal static bool IsInheritanceNode(DependencyObject d, DependencyProperty dp, out InheritanceBehavior inheritanceBehavior)
        {
            inheritanceBehavior = InheritanceBehavior.Default;
            FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

            if (frameworkPropertyMetadata != null)
            {
                FrameworkObject frameworkObject = new FrameworkObject(d);
                if (!frameworkObject.IsValid)
                {
                    return(false);
                }
                if (frameworkObject.InheritanceBehavior != InheritanceBehavior.Default && !frameworkPropertyMetadata.OverridesInheritanceBehavior)
                {
                    inheritanceBehavior = frameworkObject.InheritanceBehavior;
                }
                if (frameworkPropertyMetadata.Inherits)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassCleanupAttribute"/> class.
 /// ClassCleanupAttribute
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassCleanup Inheritance Behavior
 /// </param>
 public ClassCleanupAttribute(InheritanceBehavior inheritanceBehavior)
 {
     this.InheritanceBehavior = inheritanceBehavior;
 }
Example #23
0
        // Token: 0x06000C71 RID: 3185 RVA: 0x0002EDAC File Offset: 0x0002CFAC
        internal static bool IsInheritanceNode(FrameworkContentElement fce, DependencyProperty dp, out InheritanceBehavior inheritanceBehavior)
        {
            inheritanceBehavior = InheritanceBehavior.Default;
            FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(fce.DependencyObjectType) as FrameworkPropertyMetadata;

            if (frameworkPropertyMetadata != null)
            {
                if (fce.InheritanceBehavior != InheritanceBehavior.Default && !frameworkPropertyMetadata.OverridesInheritanceBehavior)
                {
                    inheritanceBehavior = fce.InheritanceBehavior;
                }
                return(frameworkPropertyMetadata.Inherits);
            }
            return(false);
        }
Example #24
0
        // Invalidate all the properties that may have changed as a result of
        //  changing this element's parent in the logical (and sometimes visual tree.)
        internal FrugalObjectList <DependencyProperty> InvalidateTreeDependentProperties(TreeChangeInfo parentTreeState, bool isSelfInheritanceParent, bool wasSelfInheritanceParent)
        {
            AncestorChangeInProgress = true;

            InVisibilityCollapsedTree = false;  // False == we don't know whether we're in a visibility collapsed tree.

            if (parentTreeState.TopmostCollapsedParentNode == null)
            {
                // There is no ancestor node with Visibility=Collapsed.
                //  See if "fe" is the root of a collapsed subtree.
                if (Visibility == Visibility.Collapsed)
                {
                    // This is indeed the root of a collapsed subtree.
                    //  remember this information as we proceed on the tree walk.
                    parentTreeState.TopmostCollapsedParentNode = this;

                    // Yes, this FE node is in a visibility collapsed subtree.
                    InVisibilityCollapsedTree = true;
                }
            }
            else
            {
                // There is an ancestor node somewhere above us with
                //  Visibility=Collapsed.  We're in a visibility collapsed subtree.
                InVisibilityCollapsedTree = true;
            }


            try
            {
                // Style property is a special case of a non-inherited property that needs
                // invalidation for parent changes. Invalidate StyleProperty if it hasn't been
                // locally set because local value takes precedence over implicit references
                if (IsInitialized && !HasLocalStyle && (this != parentTreeState.Root))
                {
                    UpdateStyleProperty();
                }

                Style            selfStyle       = null;
                Style            selfThemeStyle  = null;
                DependencyObject templatedParent = null;

                int         childIndex         = -1;
                ChildRecord childRecord        = new ChildRecord();
                bool        isChildRecordValid = false;

                selfStyle       = Style;
                selfThemeStyle  = ThemeStyle;
                templatedParent = TemplatedParent;
                childIndex      = TemplateChildIndex;

                // StyleProperty could have changed during invalidation of ResourceReferenceExpressions if it
                // were locally set or during the invalidation of unresolved implicitly referenced style
                bool hasStyleChanged = HasStyleChanged;

                // Fetch selfStyle, hasStyleChanged and childIndex for the current node
                FrameworkElement.GetTemplatedParentChildRecord(templatedParent, childIndex, out childRecord, out isChildRecordValid);

                FrameworkElement        parentFE;
                FrameworkContentElement parentFCE;
                bool hasParent = FrameworkElement.GetFrameworkParent(this, out parentFE, out parentFCE);

                DependencyObject    parent = null;
                InheritanceBehavior parentInheritanceBehavior = InheritanceBehavior.Default;
                if (hasParent)
                {
                    if (parentFE != null)
                    {
                        parent = parentFE;
                        parentInheritanceBehavior = parentFE.InheritanceBehavior;
                    }
                    else
                    {
                        parent = parentFCE;
                        parentInheritanceBehavior = parentFCE.InheritanceBehavior;
                    }
                }

                if (!TreeWalkHelper.SkipNext(InheritanceBehavior) && !TreeWalkHelper.SkipNow(parentInheritanceBehavior))
                {
                    // Synchronize InheritanceParent
                    this.SynchronizeInheritanceParent(parent);
                }
                else if (!IsSelfInheritanceParent)
                {
                    // Set IsSelfInheritanceParet on the root node at a tree boundary
                    // so that all inheritable properties are cached on it.
                    SetIsSelfInheritanceParent();
                }

                // Loop through all cached inheritable properties for the parent to see if they should be invalidated.
                return(TreeWalkHelper.InvalidateTreeDependentProperties(parentTreeState, /* fe = */ this, /* fce = */ null, selfStyle, selfThemeStyle,
                                                                        ref childRecord, isChildRecordValid, hasStyleChanged, isSelfInheritanceParent, wasSelfInheritanceParent));
            }
            finally
            {
                AncestorChangeInProgress  = false;
                InVisibilityCollapsedTree = false;  // 'false' just means 'we don't know' - see comment at definition of the flag.
            }
        }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClassCleanupAttribute"/> class.
 /// </summary>
 /// <param name="inheritanceBehavior">
 /// Specifies the ClassCleanup Inheritance Behavior
 /// </param>
 public ClassCleanupAttribute(InheritanceBehavior inheritanceBehavior)
     : this(inheritanceBehavior, null)
 {
 }