Exemplo n.º 1
0
        private void EnqueueAttribute(XamlAttribute attribute)
        {
            var nodeForAttribute = new ProtoParserNode();
            switch (attribute.Type)
            {
                case AttributeType.CtorDirective:
                case AttributeType.Name:
                case AttributeType.Directive:
                    nodeForAttribute.NodeType = NodeType.Directive;
                    break;
                case AttributeType.Property:
                    nodeForAttribute.NodeType = NodeType.Attribute;
                    break;
                case AttributeType.AttachableProperty:
                    nodeForAttribute.NodeType = NodeType.Attribute;
                    break;
                default:
                    throw new ProtoParserException("The type of the attribute is unknown");
            }

            var property = attribute.Property;
            var convertCrlFtoLf = property == null;

            nodeForAttribute.PropertyAttribute = property;
            var xamlText = new TextBuffer();
            xamlText.Append(attribute.Value, false, convertCrlFtoLf);
            nodeForAttribute.PropertyAttributeText = xamlText;
            nodeForAttribute.Prefix = attribute.Locator.Prefix;

            nodes.Enqueue(nodeForAttribute);
        }
Exemplo n.º 2
0
        private void ReadPropertyElement(PropertyLocator locator, XamlType tagType, bool isEmptyTag)
        {
            var xamlBareAttributes = EnqueuePrefixDefinitionsAndGetTheRestOfAttributes();

            var namespaceUri = xmlReader.NamespaceURI;
            var tagIsRoot = stack.Depth == 1;
            var dottedProperty = GetDottedProperty(tagType, locator);

            var node = new ProtoParserNode
            {
                Prefix = locator.Prefix,
                TypeNamespace = namespaceUri,
                IsEmptyTag = isEmptyTag
            };

            var fullyFledgedAttributes = GetAttributes(xamlBareAttributes, node.Type).ToList();

            if (stack.Depth > 0)
            {
                stack.IsCurrentlyInsideContent = false;
            }

            node.PropertyElement = dottedProperty;

            if (!node.IsEmptyTag)
            {
                stack.CurrentProperty = node.PropertyElement;
                node.NodeType = NodeType.PropertyElement;
            }
            else
            {
                node.NodeType = NodeType.EmptyPropertyElement;
            }

            nodes.Enqueue(node);

            EnqueueAttributes(fullyFledgedAttributes);
        }
Exemplo n.º 3
0
        private void ReadObjectElement(XamlName name, bool isEmptyTag)
        {
            var attributes = EnqueuePrefixDefinitionsAndGetTheRestOfAttributes();

            var node = new ProtoParserNode {Prefix = name.Prefix, IsEmptyTag = isEmptyTag};

            var namespaceUri = xmlReader.NamespaceURI;
            node.TypeNamespace = namespaceUri;

            var xamlAttributes = ReadObjectElementObject(namespaceUri, name.PropertyName, node, attributes);
            nodes.Enqueue(node);

            EnqueueAttributes(xamlAttributes);
        }
Exemplo n.º 4
0
        private IEnumerable<XamlAttribute> ReadObjectElementObject(string xmlns, string name, ProtoParserNode node, List<UnboundAttribute> xamlBareAttributes)
        {
            var xamlTypeName = new XamlTypeName(xmlns, name);
            node.Type = typingCore.GetWithFullAddress(xamlTypeName);

            var attributes = GetAttributes(xamlBareAttributes, node.Type).ToList();

            if (stack.Depth > 0)
            {
                stack.IsCurrentlyInsideContent = true;
            }

            if (!node.IsEmptyTag)
            {
                node.NodeType = NodeType.Element;
                stack.Push(node.Type, node.TypeNamespace);
            }
            else
            {
                node.NodeType = NodeType.EmptyElement;
            }

            return attributes;
        }
Exemplo n.º 5
0
 private void Read()
 {
     FillQueue();
     currentNode = nodes.Dequeue();
 }