コード例 #1
0
        public TypeCollection <NodeType> GetAllTypes()
        {
            TypeCollection <NodeType> types = new TypeCollection <NodeType>(this.SchemaRoot);

            this.GetAllTypes(types);
            return(types);
        }
コード例 #2
0
ファイル: SchemaRoot.cs プロジェクト: kimduquan/DMIS
        //================================================================================ Construction

        protected SchemaRoot()
        {
            _propertyTypes    = new TypeCollection <PropertyType>(this);
            _nodeTypes        = new TypeCollection <NodeType>(this);
            _contentListTypes = new TypeCollection <ContentListType>(this);
            _permissionTypes  = new TypeCollection <PermissionType>(this);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 private void GetAllTypes(TypeCollection <NodeType> types)
 {
     types.Add(this);
     foreach (NodeType subType in this.GetChildren())
     {
         subType.GetAllTypes(types);
     }
 }
コード例 #5
0
 internal virtual void AddRange(TypeCollection <T> items)
 {
     foreach (T t in items)
     {
         if (!_list.ContainsValue(t))
         {
             _list.Add(t.Name, t);
         }
     }
 }
コード例 #6
0
        public TypeCollection <NodeType> GetChildren()
        {
            TypeCollection <NodeType> children = new TypeCollection <NodeType>(this.SchemaRoot);

            foreach (NodeType nt in _children)
            {
                children.Add(nt);
            }
            return(children);
        }
コード例 #7
0
ファイル: NodeTypeManager.cs プロジェクト: kimduquan/DMIS
        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);
        }
コード例 #8
0
        //============================================================== 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);
        }
コード例 #9
0
        //================================================================================ 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);
            }
        }
コード例 #10
0
        //private static List<T> GetExclusiveTypesFromMain<T>(TypeCollection<T> mainSet, TypeCollection<T> subSet) where T : SchemaItem
        //{
        //    List<T> exclusiveTypes = new List<T>();
        //    foreach (T mainType in mainSet)
        //        if (subSet[mainType.Name] == null)
        //            exclusiveTypes.Add(mainType);
        //    return exclusiveTypes;
        //}
        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++];

                //-- ha nincs az ujban, akkor torolni kell, egyebkent a gyerekek mennek az enumeratorba
                //-- 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);
        }
コード例 #11
0
 internal TypeCollection(TypeCollection <T> initialList) : this(initialList._schemaRoot)
 {
     AddRange(initialList);
 }
コード例 #12
0
        //================================================================================ Construction

        internal PropertySet(int id, string name, ISchemaRoot schemaRoot) : base(schemaRoot, name, id)
        {
            _propertyTypes = new TypeCollection <PropertyType>(schemaRoot);
        }