private static List <NodeType> GetNodeTypeRootsToDelete(TypeCollection <NodeType> origSet, TypeCollection <NodeType> newSet) { // Walks (preorder) origSet NodeType tree and collects only deletable subtree roots. List <NodeType> _nodeTypeRootsToDelete = new List <NodeType>(); List <NodeType> _nodeTypesToEnumerate = new List <NodeType>(); // collect only roots foreach (NodeType rootNodeType in origSet) { if (rootNodeType.Parent == null) { _nodeTypesToEnumerate.Add(rootNodeType); } } int index = 0; while (index < _nodeTypesToEnumerate.Count) { NodeType currentType = _nodeTypesToEnumerate[index++]; // delete currentType if newSet does not contain it otherwise add its children to enumerator if (newSet.GetItemById(currentType.Id) == null) { _nodeTypeRootsToDelete.Add(currentType); } else { _nodeTypesToEnumerate.AddRange(currentType.GetChildren()); } } return(_nodeTypeRootsToDelete); }
public TypeCollection <NodeType> GetAllTypes() { TypeCollection <NodeType> types = new TypeCollection <NodeType>(this.SchemaRoot); this.GetAllTypes(types); return(types); }
//================================================================================ Construction protected SchemaRoot() { _propertyTypes = new TypeCollection <PropertyType>(this); _nodeTypes = new TypeCollection <NodeType>(this); _contentListTypes = new TypeCollection <ContentListType>(this); _permissionTypes = new TypeCollection <PermissionType>(this); }
private void GetAllTypes(TypeCollection <NodeType> types) { types.Add(this); foreach (NodeType subType in this.GetChildren()) { subType.GetAllTypes(types); } }
private static bool NeedToCreate <T>(TypeCollection <T> origTypes, T newType) where T : SchemaItem { // Need to create if origTypes does not contain this name or // Id of new is 0 and Id of old is not 0. T origType = origTypes[newType.Name]; return(origType == null || (newType.Id == 0 && origType.Id != 0)); }
public TypeCollection <NodeType> GetChildren() { TypeCollection <NodeType> children = new TypeCollection <NodeType>(this.SchemaRoot); foreach (NodeType nt in _children) { children.Add(nt); } return(children); }
internal virtual void AddRange(TypeCollection <T> items) { foreach (T t in items) { if (!_list.ContainsValue(t)) { _list.Add(t.Name, t); } } }
public static TypeCollection <PropertyType> GetDynamicSignature(int nodeTypeId, int contentListTypeId) { System.Diagnostics.Debug.Assert(nodeTypeId > 0); var nodePropertyTypes = NodeTypeManager.Current.NodeTypes.GetItemById(nodeTypeId).PropertyTypes; var allPropertyTypes = new TypeCollection <PropertyType>(nodePropertyTypes); if (contentListTypeId > 0) { allPropertyTypes.AddRange(NodeTypeManager.Current.ContentListTypes.GetItemById(contentListTypeId).PropertyTypes); } return(allPropertyTypes); }
// ============================================================== Tools private static List <T> GetTypesToDelete <T>(TypeCollection <T> origTypes, TypeCollection <T> newTypes) where T : SchemaItem { List <T> toDelete = new List <T>(); foreach (T origType in origTypes) { T newType = newTypes[origType.Name]; // Need to delete if newTypes does not contain this name or // Id of new is 0 and Id of old is not 0. if (newType == null || (newType.Id == 0 && newType.Id != origType.Id)) { toDelete.Add(origType); } } return(toDelete); }
//================================================================================ Construction internal NodeType(int id, string name, ISchemaRoot schemaRoot, string className, NodeType parent) : base(id, name, schemaRoot) { _declaredPropertyTypes = new TypeCollection <PropertyType>(this.SchemaRoot); _parent = parent; _children = new TypeCollection <NodeType>(this.SchemaRoot); _className = className; _nodeTypePath = name; if (parent != null) { parent._children.Add(this); //-- Inherit PropertyTypes foreach (PropertyType propType in parent.PropertyTypes) { this.PropertyTypes.Add(propType); } _nodeTypePath = String.Concat(parent._nodeTypePath, "/", _nodeTypePath); } }
//================================================================================ Construction internal PropertySet(int id, string name, ISchemaRoot schemaRoot) : base(schemaRoot, name, id) { _propertyTypes = new TypeCollection <PropertyType>(schemaRoot); }
internal TypeCollection(TypeCollection <T> initialList) : this(initialList._schemaRoot) { AddRange(initialList); }