private void Visit(XamlXmlReader reader, XamlObjectDefinition xamlObject) { while (reader.Read()) { WriteState(reader); switch (reader.NodeType) { case XamlNodeType.StartMember: _depth++; xamlObject.Members.Add(VisitMember(reader, xamlObject)); break; case XamlNodeType.StartObject: _depth++; xamlObject.Objects.Add(VisitObject(reader, xamlObject)); break; case XamlNodeType.Value: xamlObject.Value = reader.Value; break; case XamlNodeType.EndObject: _depth--; return; case XamlNodeType.EndMember: _depth--; break; default: throw new InvalidOperationException(); } } }
private XamlObjectDefinition VisitObject(XamlXmlReader reader, XamlObjectDefinition owner) { var xamlObject = new XamlObjectDefinition(reader.Type, reader.LineNumber, reader.LinePosition, owner); Visit(reader, xamlObject); return(xamlObject); }
public XamlObjectDefinition(XamlType type, int lineNumber, int linePosition, XamlObjectDefinition owner) { LineNumber = lineNumber; LinePosition = linePosition; Type = type; Owner = owner; Members = new List <XamlMemberDefinition>(); Objects = new List <XamlObjectDefinition>(); }
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")); }
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); }
public XamlMemberDefinition(XamlMember xamlMember, int lineNumber, int linePosition, XamlObjectDefinition owner = null) { // TODO: Complete member initialization // If the DeclaringType is not properly resolved, we assume it should be the owner (xamlObject) if (xamlMember.DeclaringType == null && owner != null && xamlMember.PreferredXamlNamespace != XamlConstants.XamlXmlNamespace) // e.g., x:Class, x:Name { xamlMember = new XamlMember(xamlMember.Name, owner.Type, xamlMember.IsAttachable); } this._xamlMember = xamlMember; LineNumber = lineNumber; LinePosition = linePosition; Objects = new List <XamlObjectDefinition>(); Owner = owner; }