internal void MoveTo(NodeType parent)
{
if (this.Parent == parent)
return;
if(_parent != null)
_parent.Children.Remove(this);
_parent = parent;
parent._children.Add(this);
UpdateNodeTypePath();
//==== Remove unwanted properties
//-- #1 Unwanted properties are old inherited properties thats are own properties excepting the declared properties
List<PropertyType> unwantedProps = new List<PropertyType>(this.PropertyTypes);
foreach (PropertyType declaredProperty in this.DeclaredPropertyTypes)
unwantedProps.Remove(declaredProperty);
//-- #2 Remove old inherited properties excepting the new inherited properties
foreach (PropertyType unwantedProp in unwantedProps)
if (!_parent.PropertyTypes.Contains(unwantedProp))
RemovePropertyType(unwantedProp);
//==== Inherit from new parent: add non-existent properties
foreach (PropertyType newProp in _parent.PropertyTypes)
if (!this.PropertyTypes.Contains(newProp))
AddPropertyType(newProp);
}
public void ModifyNodeType(NodeType nodeType, NodeType parent) { if (nodeType == null) { throw new ArgumentNullException("nodeType"); } if (nodeType.SchemaRoot != this) { throw new SchemaEditorCommandException(SR.Exceptions.Schema.Msg_InconsistentHierarchy); } if (parent.SchemaRoot != this) { throw new SchemaEditorCommandException(SR.Exceptions.Schema.Msg_InconsistentHierarchy); } if (nodeType == parent) { throw new SchemaEditorCommandException(SR.Exceptions.Schema.Msg_CircularReference); } if (nodeType.Parent != parent) { nodeType.MoveTo(parent); } }