Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (34 sloc) 0.997 kB
using Microsoft.Web.XmlTransform;
using System.Linq;
using System.Xml;
namespace AppHarbor.TransformTester.Transforms
{
public class Merge : Transform
{
public Merge()
: base(TransformFlags.UseParentAsTargetNode)
{
}
protected override void Apply()
{
Apply((XmlElement)TargetNode, (XmlElement)TransformNode);
}
public void Apply(XmlElement targetElement, XmlElement transformElement)
{
var targetChildElement = targetElement.ChildNodes.OfType<XmlElement>().FirstOrDefault(x => x.LocalName == transformElement.LocalName);
if (targetChildElement == null)
{
InsertTransformElement(targetElement, transformElement);
return;
}
foreach (var transformChildElement in transformElement.ChildNodes.OfType<XmlElement>())
{
Apply(targetChildElement, transformChildElement);
}
}
protected virtual void InsertTransformElement(XmlElement targetElement, XmlElement transformElement)
{
targetElement.AppendChild(transformElement);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.