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); } } }
private void BuildPermissions(DataTable table) { foreach (DataRow row in table.Rows) { int id = TypeConverter.ToInt32(row["PermissionID"]); string name = TypeConverter.ToString(row["Name"]); CreatePermissionType(id, name); } }
private static Dictionary <int, DataType> BuildDataTypeHelper(DataSet dataSet) { Dictionary <int, DataType> dataTypeHelper = new Dictionary <int, DataType>(); foreach (DataRow row in dataSet.Tables["DataTypes"].Rows) { dataTypeHelper.Add(TypeConverter.ToInt32(row["DataTypeID"]), (DataType)Enum.Parse(typeof(DataType), TypeConverter.ToString(row["Name"]))); } return(dataTypeHelper); }
private static int GetPropertyTypeIdByName(DataSet dataSet, string name) { foreach (DataRow row in dataSet.Tables["PropertyTypes"].Rows) { if (TypeConverter.ToString(row["Name"]) == name) { return(TypeConverter.ToInt32(row[0])); } } return(0); }
private void BuildPropertyTypes(DataTable table, Dictionary <int, DataType> dataTypes) { foreach (DataRow row in table.Rows) { int id = TypeConverter.ToInt32(row["PropertyTypeID"]); string name = TypeConverter.ToString(row["Name"]); DataType dataType = dataTypes[TypeConverter.ToInt32(row["DataTypeID"])]; int mapping = TypeConverter.ToInt32(row["Mapping"]); bool isContentListProperty = TypeConverter.ToBoolean(row["IsContentListProperty"]); CreatePropertyType(id, name, dataType, mapping, isContentListProperty); } }
private static Dictionary <int, PropertySetType> BuildPropertySetTypeHelper(DataSet dataSet) { Dictionary <int, PropertySetType> dataTypeHelper = new Dictionary <int, PropertySetType>(); foreach (DataRow row in dataSet.Tables["PropertySetTypes"].Rows) { switch (TypeConverter.ToString(row["Name"])) { case "NodeType": dataTypeHelper.Add(TypeConverter.ToInt32(row["PropertySetTypeID"]), PropertySetType.NodeType); break; case "ContentListType": dataTypeHelper.Add(TypeConverter.ToInt32(row["PropertySetTypeID"]), PropertySetType.ContentListType); break; } } return(dataTypeHelper); }
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); } try { if (isDeclared) { AddPropertyTypeToPropertySet(propertyType, propertySet); } } catch (ArgumentNullException ex) { SnLog.WriteWarning("Unknown property set: " + propertySetId, properties: new Dictionary <string, object> { { "PropertyTypeId", propertyType.Id }, { "Content list types: ", string.Join(", ", _contentListTypes.Select(cl => cl.Id)) }, { "Node types: ", string.Join(", ", _nodeTypes.Select(nt => string.Format("{0} ({1})", nt.Name, nt.Id))) }, }); throw new InvalidSchemaException("Unknown property set: " + propertySetId, ex); } } }
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); } } } }