/// <summary> /// Adds fields to a RecordAttribute object. /// </summary> /// <param name="recordAttribute">The RecordAttribute attribute to add fields to.</param> /// <param name="recordAttributeNode">The XmlNode containing the fields.</param> private static void AddFields(RecordAttributes recordAttribute, XmlNode recordAttributeNode) { foreach (XmlNode fieldNode in recordAttributeNode.SelectNodes("Field")) { FieldAttributes field = new FieldAttributes { Id = fieldNode.Attributes["name"].Value, Description = fieldNode.Attributes["name"].Value, IsWriteBack = false, FieldType = TranslateFieldType(fieldNode.Attributes["type"].Value) }; recordAttribute[field.Id] = field; } }
/// <summary> /// Recursively adds RecordAttributes to a SystemImport object. /// </summary> /// <param name="import">The SystemImport object.</param> /// <param name="recordAttributeNode">The XmlNode representing the RecordAttributes object to be created.</param> /// <param name="parentId">The id of the parent RecordAttributes object.</param> private static void AddRecordAttributeRecursive(SystemImport import, XmlNode recordAttributeNode, string parentId) { // Create the RecordAttributes object. RecordAttributes recordAttribute = new RecordAttributes { Id = recordAttributeNode.Attributes["name"].Value, ParentId = parentId, Mandatory = true, Description = recordAttributeNode.Attributes["name"].Value }; // Add it to the SystemImport object. import[recordAttribute.Id] = recordAttribute; // Add the fields. AddFields(recordAttribute, recordAttributeNode); // Now recursively add each child Record XmlNode. foreach (XmlNode childRecordAttribute in recordAttributeNode.SelectNodes("Record")) { AddRecordAttributeRecursive(import, childRecordAttribute, recordAttribute.Id); } }