private void Transform(ElementNode node, IList<Node> body)
        {
            AttributeNode forAttribute = node.GetAttribute("for");
            AttributeNode forType = node.GetAttribute("fortype");
            AttributeNode forProperty = node.GetAttribute("forproperty");

            if(forAttribute!=null)
            {
                // put in as content property
                node.Attributes.Remove(forAttribute);
                node.RemoveAttributesByName("name");
                node.RemoveAttributesByName("value");
                var nameNode = new ExpressionNode(forAttribute.Value.GetPropertyNameSnippet());

                var valueNode = new ConditionNode("resource!=null")
                                     	{
                                     		Nodes = new List<Node>()
                                     		        	{
                                     		        		new ExpressionNode(forAttribute.Value)
                                     		        	}
                                     	};
                 SetNodeNameAndValue(node, valueNode, nameNode, body, forAttribute);
            }
            else if(forType!=null)
            {
                if(forProperty==null)
                {
                    throw new Exception("Must have both a forProperty attribute if using the forType attribute.");
                }
                node.Attributes.Remove(forType);
                node.Attributes.Remove(forProperty);
                node.RemoveAttributesByName("name");
                 SetNodeNameAndValue(node, null, new TextNode(string.Concat(forType.Value, ".", forProperty.Value)), body, forAttribute);
            }
        }
 public override void DoReplace(ElementNode node, IList<Node> body)
 {
     body.Clear();
     Node newBody = node.GetAttribute("for").Value.GetPropertyValueNode();
     body.Add(newBody);
 }
 public override void DoReplace(ElementNode node, IList<Node> body)
 {
     AttributeNode forAttribute = node.GetAttribute(ReplacementSpecification.OriginalAttributeName);
     AddAttribute(node, "name", new ExpressionNode(forAttribute.Value.GetPropertyNameSnippet()));
 }
예제 #4
0
		public override void DoReplace(ElementNode node, IList<Node> body)
		{
			AttributeNode forAttribute = node.GetAttribute(ReplacementSpecification.OriginalAttributeName);
			AddAttribute(node, "value", forAttribute.Value.GetPropertyValueNode());
		}