internal void AddNodes(ScopeNode[] items, int index)
{
if (!this._initialized)
{
throw new Exception(Microsoft.ManagementConsole.Internal.Utility.LoadResourceString(Microsoft.ManagementConsole.Internal.Strings.NodeSyncManagerNotInitialized));
}
if (items.Length != 0)
{
int capacity = this.CountNodesForInsertion(items);
InsertScopeNodesCommandWriter writer = new InsertScopeNodesCommandWriter(capacity);
ScopeNode[] nodeList = new ScopeNode[capacity];
int currentNodesIndex = 0;
try
{
this.AddTreeToInsertionList(writer, nodeList, ref currentNodesIndex, index, items);
foreach (ScopeNode node in nodeList)
{
ViewDescriptionCollection viewDescriptionsInternal = node.ViewDescriptionsInternal;
if (viewDescriptionsInternal != null)
{
viewDescriptionsInternal.Initialize();
}
}
this._snapInPlatform.ProcessCommand(writer.Flush());
}
catch
{
TraceSources.ExecutiveSource.TraceEvent(TraceEventType.Warning, 12, "NodeSyncManager.AddNodes() failed");
throw;
}
finally
{
writer.Dispose();
}
foreach (ScopeNode node2 in nodeList)
{
node2.Children.ItemsChanged += new ScopeNodeCollection.ScopeNodeCollectionEventHandler(this.OnNodesChanged);
node2.Changed += new Node.NodeChangedEventHandler(this.OnNodeChanged);
node2.SharedDataChanged += new ScopeNode.SharedDataChangedEventHandler(this.OnNodeSharedDataChanged);
this._nodes.Add(node2.Id, node2);
node2.OnNodeSyncManagerAdd();
}
}
}