public void SetValues( IEnumerable<string> nodePaths )
{
var nodePathsList = nodePaths.ToList();
if ( nodePathsList.Any() )
{
var ids = new List<string>();
var names = new List<string>();
InitialItemParentIds = string.Empty;
// Get any prefixes that were defined with the mergefield
var prefixedMergeFieldIds = GetPrefixedMergeFieldIds();
foreach ( string nodePath in nodePathsList )
{
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 ( InitialItemParentIds == string.Empty && nodes.Count > 1 )
{
InitialItemParentIds = nodes.Take( nodes.Count - 1 ).ToList().AsDelimited( "," );
}
}
}
ItemIds = ids;
ItemNames = names;
}
else
{
ItemId = "0";
ItemName = "Add Merge Field";
}
}