public void SetValue( string nodePath )
{
if ( ! string.IsNullOrWhiteSpace(nodePath))
{
// Get any prefixes that were defined with the mergefield
var prefixedMergeFieldIds = GetPrefixedMergeFieldIds();
var nodes = new List<string>();
string workingPath = nodePath;
// Check to see if the nodepath starts with one of the prefixedMergeFields. If so
// the node path should not split its items on the first pipe character
foreach ( string fieldId in prefixedMergeFieldIds )
{
if ( nodePath.StartsWith( fieldId ) )
{
nodes.Add( fieldId );
workingPath = nodePath.Substring( fieldId.Length );
break;
}
}
workingPath.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ).ToList()
.ForEach( n => nodes.Add( n ) );
if ( nodes.Count > 0 )
{
ItemId = nodePath;
ItemName = nodes[nodes.Count -1];
if ( nodes.Count > 1 )
{
InitialItemParentIds = nodes.Take( nodes.Count - 1 ).ToList().AsDelimited( "," );
}
}
}
else
{
ItemId = "0";
ItemName = "Add Merge Field";
}
}