private void ImportField(XmlNode fieldNode, ObjectClass obj) { XmlAttribute attr = null; if (fieldNode.Name == "forms") { obj.Form = this.ConvertXmlToString(fieldNode.InnerXml); return; } if (fieldNode.Name == "fieldname") { attr = fieldNode.Attributes["expression"]; if (attr != null) { obj[SystemProperty.Name].Evaluated = true; obj[SystemProperty.Name].Expression = attr.Value; } return; } attr = fieldNode.Attributes["name"]; if (attr == null) { return; } string fieldName = attr.Value; attr = fieldNode.Attributes["type"]; if (attr == null) { return; } FieldType fieldType = Utils.Parse(attr.Value); Field field = this.Database.Classes.AddField(obj, fieldName, fieldType); attr = fieldNode.Attributes["category"]; if (attr != null) { field.Category = attr.Value; } attr = fieldNode.Attributes["group"]; if (attr != null) { field.Group = bool.Parse(attr.Value); } field.Comment = fieldNode.AttributeValueOrDefault("comment"); attr = fieldNode.Attributes["expression"]; if (attr != null && field.FieldType == FieldType.Text) { field.Evaluated = true; field.Expression = attr.Value; } attr = fieldNode.Attributes["order"]; if (attr != null) { field.Order = int.Parse(attr.Value); } switch (fieldType) { case FieldType.Url: attr = fieldNode.Attributes["method"]; if (attr != null) { UrlProperty.Get(field).Type = UrlProperty.Parse(attr.Value); } break; case FieldType.Text: XmlAttribute xmlTextDef = fieldNode.Attributes["default"]; if (xmlTextDef != null) { field.DefaultValue.AsText = xmlTextDef.Value; } break; case FieldType.Select: XmlAttribute xmlValues = fieldNode.Attributes["values"]; if (xmlValues != null) { List <string> sc = (List <string>)field.Data; sc.AddRange(xmlValues.Value.Split(new char[] { ';' })); XmlAttribute xmlValuesDef = fieldNode.Attributes["default"]; if (xmlValuesDef != null) { field.DefaultValue.AsInteger = sc.IndexOf(xmlValuesDef.Value); } } break; case FieldType.Number: attr = fieldNode.Attributes["default"]; if (attr != null) { field.DefaultValue.AsDecimal = decimal.Parse(attr.Value); } NumberProperty prop = (NumberProperty)field.Data; attr = fieldNode.Attributes["decimal"]; if (attr != null) { prop.DecimalPlaces = int.Parse(attr.Value); } attr = fieldNode.Attributes["maximum"]; if (attr != null) { prop.Maximum = decimal.Parse(attr.Value); prop.Bounds = true; } attr = fieldNode.Attributes["minimum"]; if (attr != null) { prop.Minimum = decimal.Parse(attr.Value); prop.Bounds = true; } attr = fieldNode.Attributes["increment"]; if (attr != null) { prop.Increment = decimal.Parse(attr.Value); } attr = fieldNode.Attributes["thousands"]; if (attr != null) { prop.Thousands = bool.Parse(attr.Value); } prop.Prefix = fieldNode.AttributeValueOrDefault("prefix"); prop.Suffix = fieldNode.AttributeValueOrDefault("suffix"); break; case FieldType.List: XmlAttribute xmlListRef = fieldNode.Attributes["ref_guid"]; if (xmlListRef != null) { ListProperty.Get(field).Reference = Database.Classes[new Guid(xmlListRef.Value)]; } else { xmlListRef = fieldNode.Attributes["reference"]; if (xmlListRef != null) { ImportObjectClass ic_list = this[xmlListRef.Value]; ListProperty.Get(field).Reference = Database.Classes[ic_list.Identifier]; } } break; case FieldType.Boolean: XmlAttribute xmlBoolDef = fieldNode.Attributes["default"]; if (xmlBoolDef != null) { field.DefaultValue.AsBoolean = bool.Parse(xmlBoolDef.Value); } break; case FieldType.Date: XmlAttribute xmlDateDef = fieldNode.Attributes["default"]; if (xmlDateDef != null) { field.DefaultValue.AsDateTime = DateTime.Parse(xmlDateDef.Value); } attr = fieldNode.Attributes["time"]; if (attr != null) { DateProperty.Get(field).ViewTime = bool.Parse(attr.Value); } break; case FieldType.Table: XmlAttribute xmlTableCols = fieldNode.Attributes["columns"]; List <ColumnProperty> list = new List <ColumnProperty>(); if (xmlTableCols != null) { foreach (string col in xmlTableCols.Value.Split(new char[] { ';' })) { list.Add(new ColumnProperty(col)); } } else { foreach (XmlNode xmlColumn in fieldNode.ChildNodes) { XmlAttribute xmlColName = xmlColumn.Attributes["name"]; if (xmlColName != null) { string colName = xmlColName.Value; ColumnProperty cp = new ColumnProperty(colName); XmlAttribute xmlColRef = xmlColumn.Attributes["ref_guid"]; if (xmlColRef != null) { cp.Reference = Database.Classes[new Guid(xmlColRef.Value)]; } else { xmlColRef = xmlColumn.Attributes["reference"]; if (xmlColRef != null) { ImportObjectClass c_ref = this[xmlColRef.Value]; cp.Reference = Database.Classes[c_ref.Identifier]; } } attr = xmlColumn.Attributes["width"]; if (attr != null) { cp.Width = int.Parse(attr.Value); } attr = xmlColumn.Attributes["min_width"]; if (attr != null) { cp.MinWidth = int.Parse(attr.Value); } attr = xmlColumn.Attributes["visible"]; if (attr != null) { cp.Visible = bool.Parse(attr.Value); } attr = xmlColumn.Attributes["resizable"]; if (attr != null) { cp.Resizable = bool.Parse(attr.Value); } attr = xmlColumn.Attributes["frozen"]; if (attr != null) { cp.Frozen = bool.Parse(attr.Value); } attr = xmlColumn.Attributes["div_width"]; if (attr != null) { cp.DividerWidth = int.Parse(attr.Value); } attr = xmlColumn.Attributes["auto_size"]; if (attr != null) { cp.AutoSize = bool.Parse(attr.Value); } attr = xmlColumn.Attributes["fill_weight"]; if (attr != null) { cp.FillWeight = int.Parse(attr.Value); } list.Add(cp); } } } ((List <ColumnProperty>)field.Data).AddRange(list); break; case FieldType.Rating: XmlAttribute xmlRaitDef = fieldNode.Attributes["default"]; if (xmlRaitDef != null) { field.DefaultValue.AsDecimal = decimal.Parse(xmlRaitDef.Value); } break; case FieldType.Reference: XmlAttribute xmlRef = fieldNode.Attributes["ref_guid"]; if (xmlRef != null) { ReferenceProperty.Get(field).Reference = Database.Classes[new Guid(xmlRef.Value)]; } else { xmlRef = fieldNode.Attributes["reference"]; if (xmlRef != null) { ImportObjectClass ic_ref = this[xmlRef.Value]; ReferenceProperty.Get(field).Reference = Database.Classes[ic_ref.Identifier]; } } break; } }