Пример #1
0
 private void BuildPropertyTypeAssignments(DataTable table)
 {
     foreach (DataRow row in table.Rows)
     {
         int          propertyTypeId = TypeConverter.ToInt32(row["PropertyTypeId"]);
         int          propertySetId  = TypeConverter.ToInt32(row["PropertySetID"]);
         bool         isDeclared     = TypeConverter.ToBoolean(row["IsDeclared"]);
         PropertyType propertyType   = _propertyTypes.GetItemById(propertyTypeId);
         if (propertyType == null)
         {
             throw new InvalidSchemaException(String.Concat(SR.Exceptions.Schema.Msg_PropertyTypeDoesNotExist, ": id=", propertyTypeId));
         }
         PropertySet propertySet = null;
         if (propertyType.IsContentListProperty)
         {
             propertySet = _contentListTypes.GetItemById(propertySetId);
         }
         else
         {
             propertySet = _nodeTypes.GetItemById(propertySetId);
         }
         if (isDeclared)
         {
             AddPropertyTypeToPropertySet(propertyType, propertySet);
         }
     }
 }
Пример #2
0
        private void BuildPropertySets(DataTable table, Dictionary <int, PropertySetType> propertySetTypes)
        {
            List <NodeTypeInfo> ntiList = new List <NodeTypeInfo>();

            foreach (DataRow row in table.Rows)
            {
                int             id              = TypeConverter.ToInt32(row["PropertySetID"]);
                int             parentID        = row["ParentID"] is DBNull ? 0 : TypeConverter.ToInt32(row["ParentID"]);
                string          name            = TypeConverter.ToString(row["Name"]);
                string          className       = row["ClassName"] is DBNull ? null : TypeConverter.ToString(row["ClassName"]);
                PropertySetType propertySetType = propertySetTypes[TypeConverter.ToInt32(row["PropertySetTypeID"])];
                switch (propertySetType)
                {
                case PropertySetType.NodeType:
                    ntiList.Add(new NodeTypeInfo(id, parentID, name, className));
                    break;

                case PropertySetType.ContentListType:
                    CreateContentListType(id, name);
                    break;

                default:
                    throw new InvalidSchemaException(String.Concat(SR.Exceptions.Schema.Msg_UnknownPropertySetType, propertySetType));
                }
            }
            while (ntiList.Count > 0)
            {
                for (int i = ntiList.Count - 1; i >= 0; i--)
                {
                    NodeTypeInfo nti    = ntiList[i];
                    NodeType     parent = null;
                    if (nti.ParentId == 0 || ((parent = _nodeTypes.GetItemById(nti.ParentId)) != null))
                    {
                        CreateNodeType(nti.Id, _nodeTypes.GetItemById(nti.ParentId), nti.Name, nti.ClassName);
                        ntiList.Remove(nti);
                    }
                }
            }
        }
Пример #3
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);
        }