Beispiel #1
0
 private bool IsLiteralInlineText(object value, XamlMemberDefinition member, XamlObjectDefinition xamlObject)
 {
     return(value is string &&
            (
                xamlObject.Type.Name == nameof(Controls.TextBlock) ||
                xamlObject.Type.Name == nameof(Documents.Bold) ||
                xamlObject.Type.Name == nameof(Documents.Hyperlink) ||
                xamlObject.Type.Name == nameof(Documents.Italic) ||
                xamlObject.Type.Name == nameof(Documents.Underline)
            ) &&
            (member.Member.Name == "_UnknownContent" || member.Member.Name == "Inlines"));
 }
Beispiel #2
0
        public bool IsAttachedProperty(XamlMemberDefinition member)
        {
            if (member.Member.DeclaringType != null)
            {
                var type = FindType(member.Member.DeclaringType);

                if (type != null)
                {
                    return(_isAttachedProperty(type, member.Member.Name));
                }
            }

            return(false);
        }
Beispiel #3
0
        public DependencyProperty FindDependencyProperty(XamlMemberDefinition member)
        {
            var propertyOwner = FindType(member.Member.DeclaringType);

            if (propertyOwner != null)
            {
                var propertyName = member.Member.Name;

                return(FindDependencyProperty(propertyOwner, propertyName));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        private XamlMemberDefinition VisitMember(XamlXmlReader reader, XamlObjectDefinition owner)
        {
            var member = new XamlMemberDefinition(reader.Member, reader.LineNumber, reader.LinePosition, owner);

            while (reader.Read())
            {
                WriteState(reader);

                switch (reader.NodeType)
                {
                case XamlNodeType.EndMember:
                    _depth--;
                    return(member);

                case XamlNodeType.Value:
                    if (IsLiteralInlineText(reader.Value, member, owner))
                    {
                        var run = ConvertLiteralInlineTextToRun(reader);
                        member.Objects.Add(run);
                    }
                    else
                    {
                        member.Value = reader.Value;
                    }
                    break;

                case XamlNodeType.StartObject:
                    _depth++;
                    member.Objects.Add(VisitObject(reader, owner));
                    break;

                case XamlNodeType.EndObject:
                    _depth--;
                    break;

                case XamlNodeType.NamespaceDeclaration:
                    // Skip
                    break;

                default:
                    throw new InvalidOperationException("Unable to process {2} node at Line {0}, position {1}".InvariantCultureFormat(reader.LineNumber, reader.LinePosition, reader.NodeType));
                }
            }

            return(member);
        }