Beispiel #1
0
        protected virtual WpfXamlMember GetAsContentProperty()
        {
            if (DependencyProperty == null)
            {
                // Not a DP, no fallback needed
                return(this);
            }
            Debug.Assert(!IsAttachable && !IsEvent);
            WpfXamlMember result = null;

            if (_underlyingMemberIsKnown)
            {
                PropertyInfo underlyingProperty = UnderlyingMember as PropertyInfo;
                if (underlyingProperty == null)
                {
                    // No underlying CLR property, no fallback needed
                    return(this);
                }
                result = new WpfXamlMember(DependencyProperty, underlyingProperty, DeclaringType.SchemaContext, _useV3Rules);
            }
            else
            {
                result = new WpfXamlMember(DependencyProperty, false /*isAttachable*/);
            }
            result.ApplyGetterFallback = true;
            return(result);
        }
        // Token: 0x060015DD RID: 5597 RVA: 0x0006AB78 File Offset: 0x00068D78
        private XamlMember FindRoutedEventBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            RoutedEvent routedEventFromName = EventManager.GetRoutedEventFromName(name, base.UnderlyingType);
            XamlMember  xamlMember          = null;

            if (routedEventFromName == null)
            {
                return(xamlMember);
            }
            WpfXamlType wpfXamlType;

            if (this.IsBamlScenario)
            {
                wpfXamlType = (System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(routedEventFromName.OwnerType) as WpfXamlType);
            }
            else
            {
                wpfXamlType = (System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(routedEventFromName.OwnerType) as WpfXamlType);
            }
            if (wpfXamlType != null)
            {
                xamlMember = WpfXamlType.FindKnownMember(wpfXamlType, name, isAttachable);
            }
            if (this.IsBamlScenario)
            {
                xamlMember = new WpfXamlMember(routedEventFromName, isAttachable);
            }
            else if (isAttachable)
            {
                xamlMember = this.GetAttachedRoutedEvent(name, routedEventFromName);
                if (xamlMember == null)
                {
                    xamlMember = this.GetRoutedEvent(name, routedEventFromName, skipReadOnlyCheck);
                }
                if (xamlMember == null)
                {
                    xamlMember = new WpfXamlMember(routedEventFromName, true);
                }
            }
            else
            {
                xamlMember = this.GetRoutedEvent(name, routedEventFromName, skipReadOnlyCheck);
                if (xamlMember == null)
                {
                    xamlMember = this.GetAttachedRoutedEvent(name, routedEventFromName);
                }
                if (xamlMember == null)
                {
                    xamlMember = new WpfXamlMember(routedEventFromName, false);
                }
            }
            if (this.Members.TryAdd(name, xamlMember))
            {
                return(xamlMember);
            }
            return(this.Members[name]);
        }
Beispiel #3
0
        protected override XamlMember LookupContentProperty()
        {
            XamlMember    result    = base.LookupContentProperty();
            WpfXamlMember wpfMember = result as WpfXamlMember;

            if (wpfMember != null)
            {
                result = wpfMember.AsContentProperty;
            }
            return(result);
        }
        // Token: 0x060015D6 RID: 5590 RVA: 0x0006A94C File Offset: 0x00068B4C
        protected override XamlMember LookupContentProperty()
        {
            XamlMember    xamlMember    = base.LookupContentProperty();
            WpfXamlMember wpfXamlMember = xamlMember as WpfXamlMember;

            if (wpfXamlMember != null)
            {
                xamlMember = wpfXamlMember.AsContentProperty;
            }
            return(xamlMember);
        }
        internal DependencyProperty GetDependencyProperty(Int16 propertyId)
        {
            XamlMember    member    = GetProperty(propertyId, false);
            WpfXamlMember wpfMember = member as WpfXamlMember;

            if (wpfMember != null)
            {
                Debug.Assert(wpfMember.DependencyProperty != null);
                return(wpfMember.DependencyProperty);
            }

            throw new KeyNotFoundException();
        }
        // Token: 0x060015DE RID: 5598 RVA: 0x0006AC74 File Offset: 0x00068E74
        private XamlMember FindDependencyPropertyBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            XamlMember         xamlMember = null;
            DependencyProperty dependencyProperty;

            if ((dependencyProperty = DependencyProperty.FromName(name, base.UnderlyingType)) != null)
            {
                WpfXamlType wpfXamlType;
                if (this.IsBamlScenario)
                {
                    wpfXamlType = (System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(dependencyProperty.OwnerType) as WpfXamlType);
                }
                else
                {
                    wpfXamlType = (System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(dependencyProperty.OwnerType) as WpfXamlType);
                }
                if (wpfXamlType != null)
                {
                    xamlMember = WpfXamlType.FindKnownMember(wpfXamlType, name, isAttachable);
                }
                if (xamlMember == null)
                {
                    if (this.IsBamlScenario)
                    {
                        xamlMember = new WpfXamlMember(dependencyProperty, isAttachable);
                    }
                    else if (isAttachable)
                    {
                        xamlMember = this.GetAttachedDependencyProperty(name, dependencyProperty);
                        if (xamlMember == null)
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        xamlMember = this.GetRegularDependencyProperty(name, dependencyProperty, skipReadOnlyCheck);
                        if (xamlMember == null)
                        {
                            xamlMember = this.GetAttachedDependencyProperty(name, dependencyProperty);
                        }
                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(dependencyProperty, false);
                        }
                    }
                    return(this.CacheAndReturnXamlMember(xamlMember));
                }
            }
            return(xamlMember);
        }
Beispiel #7
0
        // Token: 0x060015BC RID: 5564 RVA: 0x0006A5D4 File Offset: 0x000687D4
        protected virtual WpfXamlMember GetAsContentProperty()
        {
            if (this.DependencyProperty == null)
            {
                return(this);
            }
            WpfXamlMember wpfXamlMember;

            if (this._underlyingMemberIsKnown)
            {
                PropertyInfo propertyInfo = base.UnderlyingMember as PropertyInfo;
                if (propertyInfo == null)
                {
                    return(this);
                }
                wpfXamlMember = new WpfXamlMember(this.DependencyProperty, propertyInfo, base.DeclaringType.SchemaContext, this._useV3Rules);
            }
            else
            {
                wpfXamlMember = new WpfXamlMember(this.DependencyProperty, false);
            }
            wpfXamlMember.ApplyGetterFallback = true;
            return(wpfXamlMember);
        }
        internal static void TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter,
                                            bool onlyLoadOneNode,
                                            bool skipJournaledProperties,
                                            bool shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer,
                                            XamlContextStack <WpfXamlFrame> stack,
                                            IStyleConnector styleConnector)
        {
            while (xamlReader.Read())
            {
                if (shouldPassLineNumberInfo)
                {
                    if (xamlLineInfo.LineNumber != 0)
                    {
                        xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition);
                    }
                }

                switch (xamlReader.NodeType)
                {
                case System.Xaml.XamlNodeType.NamespaceDeclaration:
                    xamlWriter.WriteNode(xamlReader);
                    if (stack.Depth == 0 || stack.CurrentFrame.Type != null)
                    {
                        stack.PushScope();
                        // Need to create an XmlnsDictionary.
                        // Look up stack to see if we have one earlier
                        //  If so, use that.  Otherwise new a xmlnsDictionary
                        WpfXamlFrame iteratorFrame = stack.CurrentFrame;
                        while (iteratorFrame != null)
                        {
                            if (iteratorFrame.XmlnsDictionary != null)
                            {
                                stack.CurrentFrame.XmlnsDictionary =
                                    new XmlnsDictionary(iteratorFrame.XmlnsDictionary);
                                break;
                            }
                            iteratorFrame = (WpfXamlFrame)iteratorFrame.Previous;
                        }
                        if (stack.CurrentFrame.XmlnsDictionary == null)
                        {
                            stack.CurrentFrame.XmlnsDictionary =
                                new XmlnsDictionary();
                        }
                    }
                    stack.CurrentFrame.XmlnsDictionary.Add(xamlReader.Namespace.Prefix, xamlReader.Namespace.Namespace);
                    break;

                case System.Xaml.XamlNodeType.StartObject:
                    WriteStartObject(xamlReader, xamlWriter, stack);
                    break;

                case System.Xaml.XamlNodeType.GetObject:
                    xamlWriter.WriteNode(xamlReader);
                    // If there wasn't a namespace node before this get object, need to pushScope.
                    if (stack.CurrentFrame.Type != null)
                    {
                        stack.PushScope();
                    }
                    stack.CurrentFrame.Type = stack.PreviousFrame.Property.Type;
                    break;

                case System.Xaml.XamlNodeType.EndObject:
                    xamlWriter.WriteNode(xamlReader);
                    // Freeze if required
                    if (stack.CurrentFrame.FreezeFreezable)
                    {
                        Freezable freezable = xamlWriter.Result as Freezable;
                        if (freezable != null && freezable.CanFreeze)
                        {
                            freezable.Freeze();
                        }
                    }
                    DependencyObject dependencyObject = xamlWriter.Result as DependencyObject;
                    if (dependencyObject != null && stack.CurrentFrame.XmlSpace.HasValue)
                    {
                        XmlAttributeProperties.SetXmlSpace(dependencyObject, stack.CurrentFrame.XmlSpace.Value ? "default" : "preserve");
                    }
                    stack.PopScope();
                    break;

                case System.Xaml.XamlNodeType.StartMember:
                    // ObjectWriter should NOT process PresentationOptions:Freeze directive since it is Unknown
                    // The space directive node stream should not be written because it induces object instantiation,
                    // and the Baml2006Reader can produce space directives prematurely.
                    if (!(xamlReader.Member.IsDirective && xamlReader.Member == XamlReaderHelper.Freeze) &&
                        xamlReader.Member != XmlSpace.Value &&
                        xamlReader.Member != XamlLanguage.Space)
                    {
                        xamlWriter.WriteNode(xamlReader);
                    }

                    stack.CurrentFrame.Property = xamlReader.Member;
                    if (skipJournaledProperties)
                    {
                        if (!stack.CurrentFrame.Property.IsDirective)
                        {
                            System.Windows.Baml2006.WpfXamlMember wpfMember = stack.CurrentFrame.Property as System.Windows.Baml2006.WpfXamlMember;
                            if (wpfMember != null)
                            {
                                DependencyProperty prop = wpfMember.DependencyProperty;

                                if (prop != null)
                                {
                                    FrameworkPropertyMetadata metadata = prop.GetMetadata(stack.CurrentFrame.Type.UnderlyingType) as FrameworkPropertyMetadata;
                                    if (metadata != null && metadata.Journal == true)
                                    {
                                        // Ignore the BAML for this member, unless it declares a value that wasn't journaled - namely a binding or a dynamic resource
                                        int count = 1;
                                        while (xamlReader.Read())
                                        {
                                            switch (xamlReader.NodeType)
                                            {
                                            case System.Xaml.XamlNodeType.StartMember:
                                                count++;
                                                break;

                                            case System.Xaml.XamlNodeType.StartObject:
                                                XamlType xamlType            = xamlReader.Type;
                                                XamlType bindingBaseType     = xamlType.SchemaContext.GetXamlType(typeof(BindingBase));
                                                XamlType dynamicResourceType = xamlType.SchemaContext.GetXamlType(typeof(DynamicResourceExtension));
                                                if (count == 1 && (xamlType.CanAssignTo(bindingBaseType) || xamlType.CanAssignTo(dynamicResourceType)))
                                                {
                                                    count = 0;
                                                    WriteStartObject(xamlReader, xamlWriter, stack);
                                                }
                                                break;

                                            case System.Xaml.XamlNodeType.EndMember:
                                                count--;
                                                if (count == 0)
                                                {
                                                    xamlWriter.WriteNode(xamlReader);
                                                    stack.CurrentFrame.Property = null;
                                                }
                                                break;

                                            case System.Xaml.XamlNodeType.Value:
                                                DynamicResourceExtension value = xamlReader.Value as DynamicResourceExtension;
                                                if (value != null)
                                                {
                                                    WriteValue(xamlReader, xamlWriter, stack, styleConnector);
                                                }
                                                break;
                                            }
                                            if (count == 0)
                                            {
                                                break;
                                            }
                                        }

                                        System.Diagnostics.Debug.Assert(count == 0, "Mismatch StartMember/EndMember");
                                    }
                                }
                            }
                        }
                    }
                    break;

                case System.Xaml.XamlNodeType.EndMember:
                    WpfXamlFrame currentFrame    = stack.CurrentFrame;
                    XamlMember   currentProperty = currentFrame.Property;
                    // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown
                    // The space directive node stream should not be written because it induces object instantiation,
                    // and the Baml2006Reader can produce space directives prematurely.
                    if (!(currentProperty.IsDirective && currentProperty == XamlReaderHelper.Freeze) &&
                        currentProperty != XmlSpace.Value &&
                        currentProperty != XamlLanguage.Space)
                    {
                        xamlWriter.WriteNode(xamlReader);
                    }
                    currentFrame.Property = null;
                    break;

                case System.Xaml.XamlNodeType.Value:
                    WriteValue(xamlReader, xamlWriter, stack, styleConnector);
                    break;

                default:
                    xamlWriter.WriteNode(xamlReader);
                    break;
                }

                //Only do this loop for one node if loadAsync
                if (onlyLoadOneNode)
                {
                    return;
                }
            }
        }
Beispiel #9
0
        private XamlMember FindDependencyPropertyBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            XamlMember xamlMember = null;

            // If it's a dependency property, return a wrapping XamlMember
            DependencyProperty property;

            if ((property = DependencyProperty.FromName(name, this.UnderlyingType)) != null)
            {
                // Try looking for a known member first instead of creating a new WpfXamlMember
                WpfXamlType wpfXamlType = null;
                if (IsBamlScenario)
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(property.OwnerType) as WpfXamlType;
                }
                else
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(property.OwnerType) as WpfXamlType;
                }

                if (wpfXamlType != null)
                {
                    xamlMember = FindKnownMember(wpfXamlType, name, isAttachable);
                }

                if (xamlMember == null)
                {
                    if (IsBamlScenario)
                    {
                        // In Baml Scenarios, we don't want to lookup the MemberInfo since we always know the
                        // type converter and we don't allows DeferringLoader (since the MarkupCompiler doesn't support it)
                        xamlMember = new WpfXamlMember(property, isAttachable);
                    }
                    else
                    {
                        // Try to find the MemberInfo so we can use that directly.  There's no direct way to do this
                        // with XamlType so we'll just get the XamlMember and get the underlying member
                        if (isAttachable)
                        {
                            xamlMember = GetAttachedDependencyProperty(name, property);
                            if (xamlMember == null)
                            {
                                return(null);
                            }
                        }
                        else
                        {
                            xamlMember = GetRegularDependencyProperty(name, property, skipReadOnlyCheck);
                            if (xamlMember == null)
                            {
                                xamlMember = GetAttachedDependencyProperty(name, property);
                            }

                            if (xamlMember == null)
                            {
                                xamlMember = new WpfXamlMember(property, false);
                            }
                        }
                    }
                    return(CacheAndReturnXamlMember(xamlMember));
                }
            }
            return(xamlMember);
        }
Beispiel #10
0
        private XamlMember FindRoutedEventBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            RoutedEvent re = EventManager.GetRoutedEventFromName(
                name, UnderlyingType);
            XamlMember xamlMember = null;

            if (re != null)
            {
                // Try looking for a known member first instead of creating a new WpfXamlMember
                WpfXamlType wpfXamlType = null;
                if (IsBamlScenario)
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(re.OwnerType) as WpfXamlType;
                }
                else
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(re.OwnerType) as WpfXamlType;
                }

                if (wpfXamlType != null)
                {
                    xamlMember = FindKnownMember(wpfXamlType, name, isAttachable);
                }

                if (IsBamlScenario)
                {
                    xamlMember = new WpfXamlMember(re, isAttachable);
                }
                else
                {
                    if (isAttachable)
                    {
                        xamlMember = GetAttachedRoutedEvent(name, re);
                        if (xamlMember == null)
                        {
                            xamlMember = GetRoutedEvent(name, re, skipReadOnlyCheck);
                        }

                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(re, true);
                        }
                    }
                    else
                    {
                        xamlMember = GetRoutedEvent(name, re, skipReadOnlyCheck);
                        if (xamlMember == null)
                        {
                            xamlMember = GetAttachedRoutedEvent(name, re);
                        }

                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(re, false);
                        }
                    }
                }
                if (Members.TryAdd(name, xamlMember))
                {
                    return(xamlMember);
                }
                else
                {
                    return(Members[name]);
                }
            }
            return(xamlMember);
        }
Beispiel #11
0
        private XamlMember FindDependencyPropertyBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            XamlMember xamlMember = null;

            // If it's a dependency property, return a wrapping XamlMember
            DependencyProperty property;
            if ((property = DependencyProperty.FromName(name, this.UnderlyingType)) != null)
            {
                // Try looking for a known member first instead of creating a new WpfXamlMember
                WpfXamlType wpfXamlType = null;
                if (IsBamlScenario)
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(property.OwnerType) as WpfXamlType;
                }
                else
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(property.OwnerType) as WpfXamlType;
                }

                if (wpfXamlType != null)
                {
                    xamlMember = FindKnownMember(wpfXamlType, name, isAttachable);
                }

                if (xamlMember == null)
                {
                    if (IsBamlScenario)
                    {
                        // In Baml Scenarios, we don't want to lookup the MemberInfo since we always know the 
                        // type converter and we don't allows DeferringLoader (since the MarkupCompiler doesn't support it)
                        xamlMember = new WpfXamlMember(property, isAttachable);
                    }
                    else
                    {
                        // Try to find the MemberInfo so we can use that directly.  There's no direct way to do this
                        // with XamlType so we'll just get the XamlMember and get the underlying member
                        if (isAttachable)
                        {
                            xamlMember = GetAttachedDependencyProperty(name, property);
                            if (xamlMember == null)
                            {
                                return null;
                            }
                        }
                        else
                        {
                            xamlMember = GetRegularDependencyProperty(name, property, skipReadOnlyCheck);
                            if (xamlMember == null)
                            {
                                xamlMember = GetAttachedDependencyProperty(name, property);
                            }

                            if (xamlMember == null)
                            {
                                xamlMember = new WpfXamlMember(property, false);
                            }
                        }

                    }
                    return CacheAndReturnXamlMember(xamlMember);
                }
            }
            return xamlMember;
        }
Beispiel #12
0
        private XamlMember FindRoutedEventBackedProperty(string name, bool isAttachable, bool skipReadOnlyCheck)
        {
            RoutedEvent re = EventManager.GetRoutedEventFromName(
                name, UnderlyingType);
            XamlMember xamlMember = null;
            if (re != null)
            {
                // Try looking for a known member first instead of creating a new WpfXamlMember
                WpfXamlType wpfXamlType = null;
                if (IsBamlScenario)
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.BamlSharedSchemaContext.GetXamlType(re.OwnerType) as WpfXamlType;
                }
                else
                {
                    wpfXamlType = System.Windows.Markup.XamlReader.GetWpfSchemaContext().GetXamlType(re.OwnerType) as WpfXamlType;
                }

                if (wpfXamlType != null)
                {
                    xamlMember = FindKnownMember(wpfXamlType, name, isAttachable);
                }

                if (IsBamlScenario)
                {
                    xamlMember = new WpfXamlMember(re, isAttachable);
                }
                else
                {
                    if (isAttachable)
                    {
                        xamlMember = GetAttachedRoutedEvent(name, re);
                        if (xamlMember == null)
                        {
                            xamlMember = GetRoutedEvent(name, re, skipReadOnlyCheck);
                        }

                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(re, true);
                        }
                    }
                    else
                    {
                        xamlMember = GetRoutedEvent(name, re, skipReadOnlyCheck);
                        if (xamlMember == null)
                        {
                            xamlMember = GetAttachedRoutedEvent(name, re);
                        }

                        if (xamlMember == null)
                        {
                            xamlMember = new WpfXamlMember(re, false);
                        }
                    }
                }
                if (Members.TryAdd(name, xamlMember))
                {
                    return xamlMember;
                }
                else
                {
                    return Members[name];
                }
            }
            return xamlMember;
        }
Beispiel #13
0
        internal static void TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter,
                                            bool onlyLoadOneNode,
                                            bool skipJournaledProperties,
                                            bool shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer,
                                            XamlContextStack <WpfXamlFrame> stack,
                                            IStyleConnector styleConnector)
        {
            while (xamlReader.Read())
            {
                if (shouldPassLineNumberInfo)
                {
                    if (xamlLineInfo.LineNumber != 0)
                    {
                        xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition);
                    }
                }

                switch (xamlReader.NodeType)
                {
                case System.Xaml.XamlNodeType.NamespaceDeclaration:
                    xamlWriter.WriteNode(xamlReader);
                    if (stack.Depth == 0 || stack.CurrentFrame.Type != null)
                    {
                        stack.PushScope();
                        // Need to create an XmlnsDictionary.
                        // Look up stack to see if we have one earlier
                        //  If so, use that.  Otherwise new a xmlnsDictionary
                        WpfXamlFrame iteratorFrame = stack.CurrentFrame;
                        while (iteratorFrame != null)
                        {
                            if (iteratorFrame.XmlnsDictionary != null)
                            {
                                stack.CurrentFrame.XmlnsDictionary =
                                    new XmlnsDictionary(iteratorFrame.XmlnsDictionary);
                                break;
                            }
                            iteratorFrame = (WpfXamlFrame)iteratorFrame.Previous;
                        }
                        if (stack.CurrentFrame.XmlnsDictionary == null)
                        {
                            stack.CurrentFrame.XmlnsDictionary =
                                new XmlnsDictionary();
                        }
                    }
                    stack.CurrentFrame.XmlnsDictionary.Add(xamlReader.Namespace.Prefix, xamlReader.Namespace.Namespace);
                    break;

                case System.Xaml.XamlNodeType.StartObject:
                    xamlWriter.WriteNode(xamlReader);
                    // If there's a frame but no Type, that means there
                    // was a namespace. Just set the Type
                    if (stack.Depth != 0 && stack.CurrentFrame.Type == null)
                    {
                        stack.CurrentFrame.Type = xamlReader.Type;
                    }
                    else
                    {
                        // Propagate the FreezeFreezable property from the current stack frame
                        stack.PushScope();
                        stack.CurrentFrame.Type = xamlReader.Type;
                        if (stack.PreviousFrame.FreezeFreezable)
                        {
                            stack.CurrentFrame.FreezeFreezable = true;
                        }
                    }
                    break;

                case System.Xaml.XamlNodeType.GetObject:
                    xamlWriter.WriteNode(xamlReader);
                    // If there wasn't a namespace node before this get object, need to pushScope.
                    if (stack.CurrentFrame.Type != null)
                    {
                        stack.PushScope();
                    }
                    stack.CurrentFrame.Type = stack.PreviousFrame.Property.Type;
                    break;

                case System.Xaml.XamlNodeType.EndObject:
                    xamlWriter.WriteNode(xamlReader);
                    // Freeze if required
                    if (stack.CurrentFrame.FreezeFreezable)
                    {
                        Freezable freezable = xamlWriter.Result as Freezable;
                        if (freezable != null && freezable.CanFreeze)
                        {
                            freezable.Freeze();
                        }
                    }
                    DependencyObject dependencyObject = xamlWriter.Result as DependencyObject;
                    if (dependencyObject != null && stack.CurrentFrame.XmlSpace.HasValue)
                    {
                        XmlAttributeProperties.SetXmlSpace(dependencyObject, stack.CurrentFrame.XmlSpace.Value ? "default" : "preserve");
                    }
                    stack.PopScope();
                    break;

                case System.Xaml.XamlNodeType.StartMember:
                    // ObjectWriter should NOT process PresentationOptions:Freeze directive since it is Unknown
                    // The space directive node stream should not be written because it induces object instantiation,
                    // and the Baml2006Reader can produce space directives prematurely.
                    if (!(xamlReader.Member.IsDirective && xamlReader.Member == XamlReaderHelper.Freeze) &&
                        xamlReader.Member != XmlSpace.Value &&
                        xamlReader.Member != XamlLanguage.Space)
                    {
                        xamlWriter.WriteNode(xamlReader);
                    }

                    stack.CurrentFrame.Property = xamlReader.Member;
                    if (skipJournaledProperties)
                    {
                        if (!stack.CurrentFrame.Property.IsDirective)
                        {
                            System.Windows.Baml2006.WpfXamlMember wpfMember = stack.CurrentFrame.Property as System.Windows.Baml2006.WpfXamlMember;
                            if (wpfMember != null)
                            {
                                DependencyProperty prop = wpfMember.DependencyProperty;

                                if (prop != null)
                                {
                                    FrameworkPropertyMetadata metadata = prop.GetMetadata(stack.CurrentFrame.Type.UnderlyingType) as FrameworkPropertyMetadata;
                                    if (metadata != null && metadata.Journal == true)
                                    {
                                        //
                                        int count = 1;
                                        while (xamlReader.Read())
                                        {
                                            switch (xamlReader.NodeType)
                                            {
                                            case System.Xaml.XamlNodeType.StartMember:
                                                count++;
                                                break;

                                            case System.Xaml.XamlNodeType.EndMember:
                                                count--;
                                                if (count == 0)
                                                {
                                                    xamlWriter.WriteNode(xamlReader);
                                                }
                                                break;
                                            }
                                            if (count == 0)
                                            {
                                                break;
                                            }
                                        }
                                        // shouldn't this have been a XamlReader.Skip()?
                                        System.Diagnostics.Debug.Assert(count == 0, "Mismatch StartMember/EndMember");
                                    }
                                }
                            }
                        }
                    }
                    break;

                case System.Xaml.XamlNodeType.EndMember:
                    WpfXamlFrame currentFrame    = stack.CurrentFrame;
                    XamlMember   currentProperty = currentFrame.Property;
                    // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown
                    // The space directive node stream should not be written because it induces object instantiation,
                    // and the Baml2006Reader can produce space directives prematurely.
                    if (!(currentProperty.IsDirective && currentProperty == XamlReaderHelper.Freeze) &&
                        currentProperty != XmlSpace.Value &&
                        currentProperty != XamlLanguage.Space)
                    {
                        xamlWriter.WriteNode(xamlReader);
                    }
                    currentFrame.Property = null;
                    break;

                case System.Xaml.XamlNodeType.Value:
                    if (stack.CurrentFrame.Property.IsDirective && stack.CurrentFrame.Property == XamlLanguage.Shared)
                    {
                        bool isShared;
                        if (bool.TryParse(xamlReader.Value as string, out isShared))
                        {
                            if (!isShared)
                            {
                                if (!(xamlReader is Baml2006Reader))
                                {
                                    throw new XamlParseException(SR.Get(SRID.SharedAttributeInLooseXaml));
                                }
                            }
                        }
                    }
                    // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown
                    if (stack.CurrentFrame.Property.IsDirective && stack.CurrentFrame.Property == XamlReaderHelper.Freeze)
                    {
                        bool freeze = Convert.ToBoolean(xamlReader.Value, TypeConverterHelper.InvariantEnglishUS);
                        stack.CurrentFrame.FreezeFreezable = freeze;
                        var bamlReader = xamlReader as System.Windows.Baml2006.Baml2006Reader;
                        if (bamlReader != null)
                        {
                            bamlReader.FreezeFreezables = freeze;
                        }
                    }
                    // The space directive node stream should not be written because it induces object instantiation,
                    // and the Baml2006Reader can produce space directives prematurely.
                    else if (stack.CurrentFrame.Property == XmlSpace.Value || stack.CurrentFrame.Property == XamlLanguage.Space)
                    {
                        if (typeof(DependencyObject).IsAssignableFrom(stack.CurrentFrame.Type.UnderlyingType))
                        {
                            System.Diagnostics.Debug.Assert(xamlReader.Value is string, "XmlAttributeProperties.XmlSpaceProperty has the type string.");
                            stack.CurrentFrame.XmlSpace = (string)xamlReader.Value == "default";
                        }
                    }
                    else
                    {
                        // Ideally we should check if we're inside FrameworkTemplate's Content and not register those.
                        // However, checking if the instance is null accomplishes the same with a much smaller perf impact.
                        if (styleConnector != null &&
                            stack.CurrentFrame.Instance != null &&
                            stack.CurrentFrame.Property == XamlLanguage.ConnectionId &&
                            typeof(Style).IsAssignableFrom(stack.CurrentFrame.Type.UnderlyingType))
                        {
                            styleConnector.Connect((int)xamlReader.Value, stack.CurrentFrame.Instance);
                        }

                        xamlWriter.WriteNode(xamlReader);
                    }
                    break;

                default:
                    xamlWriter.WriteNode(xamlReader);
                    break;
                }

                //Only do this loop for one node if loadAsync
                if (onlyLoadOneNode)
                {
                    return;
                }
            }
        }
Beispiel #14
0
 public WpfMemberInvoker(WpfXamlMember member) : base(member)
 {
     _member = member;
 }
 // Token: 0x060015A6 RID: 5542 RVA: 0x0006A11B File Offset: 0x0006831B
 public WpfMemberInvoker(WpfXamlMember member) : base(member)
 {
     this._member = member;
 }
Beispiel #16
0
 protected virtual WpfXamlMember GetAsContentProperty()
 { 
     if (DependencyProperty == null)
     { 
         // Not a DP, no fallback needed 
         return this;
     } 
     Debug.Assert(!IsAttachable && !IsEvent);
     WpfXamlMember result = null;
     if (_underlyingMemberIsKnown)
     { 
         PropertyInfo underlyingProperty = UnderlyingMember as PropertyInfo;
         if (underlyingProperty == null) 
         { 
             // No underlying CLR property, no fallback needed
             return this; 
         }
         result = new WpfXamlMember(DependencyProperty, underlyingProperty, DeclaringType.SchemaContext, _useV3Rules);
     }
     else 
     {
         result = new WpfXamlMember(DependencyProperty, false /*isAttachable*/); 
     } 
     result.ApplyGetterFallback = true;
     return result; 
 }