private static void WriteCreateOrModifyNodeTypes(SchemaEditor origSchema, SchemaEditor newSchema, List <PropertySet> modifiedPropertySets, SchemaWriter writer) { List <NodeType> _nodeTypesToEnumerate = new List <NodeType>(); // collect only roots foreach (NodeType rootNodeType in newSchema.NodeTypes) { if (rootNodeType.Parent == null) { _nodeTypesToEnumerate.Add(rootNodeType); } } int index = 0; while (index < _nodeTypesToEnumerate.Count) { NodeType currentType = _nodeTypesToEnumerate[index++]; NodeType origType = null; if (NeedToCreate <NodeType>(origSchema.NodeTypes, currentType)) { if (currentType.ClassName == null) { throw new InvalidSchemaException("ClassName cannot be null. NodeType: " + currentType.Name); } writer.CreateNodeType(currentType.Parent, currentType.Name, currentType.ClassName); } else { origType = origSchema.NodeTypes[currentType.Name]; string origParentName = origType.Parent == null ? null : origType.Parent.Name; string newParentName = currentType.Parent == null ? null : currentType.Parent.Name; bool parentChanged = origParentName != newParentName; if (parentChanged || origType.ClassName != currentType.ClassName) { writer.ModifyNodeType(origType, currentType.Parent, currentType.ClassName); if (!modifiedPropertySets.Contains(origType)) { modifiedPropertySets.Add(origType); } } } // Property list (origType can be null) WriteAddOrRemovePropertyTypes(origType, currentType, modifiedPropertySets, writer); // Add children to enumerator _nodeTypesToEnumerate.AddRange(currentType.GetChildren()); } }