private void AddTreeToInsertionList(InsertScopeNodesCommandWriter writer, ScopeNode[] nodeList, ref int currentNodesIndex, int index, ScopeNode[] nodes)
{
foreach (ScopeNode node in nodes)
{
if (this._nodes.ContainsKey(node.Id))
{
throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerAddTreeToInsertionListNodeExistInOneLocation));
}
if (node == null)
{
throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerInvalidNodeType));
}
ScopeNodeInsert insert = new ScopeNodeInsert();
insert.NodeData = (ScopeNodeData) node.Data;
ActionsPaneRootData data = new ActionsPaneRootData();
data.Write(node.ActionsPaneItems.Data);
insert.Actions = data;
data = new ActionsPaneRootData();
data.Write(node.ActionsPaneHelpItems.Data);
insert.HelpActions = data;
insert.InitialSharedData.SetAddedFormats(this.GenerateSharedDataFormatConfiguration(node));
insert.InitialSharedData.SetUpdatedData(this.GenerateClipboardData(node));
if (node.Parent != null)
{
insert.ParentScopeNodeId = node.Parent.Id;
}
insert.InsertionIndex = index;
writer.WriteScopeNodeInsert(insert);
nodeList[currentNodesIndex++] = node;
index++;
if (node.Children.Count > 0)
{
this.AddTreeToInsertionList(writer, nodeList, ref currentNodesIndex, 0, node.Children.ToArray());
}
}
}