Example #1
0
        private static void AddField(FieldObject fieldObject, XmlElement parentElement, XmlDocument document, IList
                                     <FieldObject> fieldList)
        {
            IList <FieldObject> childrenFields = FindChildrenFields(fieldObject, fieldList);
            XmlElement          field          = document.CreateElement("field");

            field.SetAttribute("name", fieldObject.GetName());
            if (!childrenFields.IsEmpty())
            {
                foreach (FieldObject childField in childrenFields)
                {
                    AddField(childField, field, document, fieldList);
                }
            }
            else
            {
                if (fieldObject.GetValue() != null && !String.IsNullOrEmpty(fieldObject.GetValue()))
                {
                    XmlElement value = document.CreateElement("value");
                    value.InnerText = fieldObject.GetValue();
                    field.AppendChild(value);
                }
                else
                {
                    logger.Info(XfdfConstants.EMPTY_FIELD_VALUE_ELEMENT);
                }
            }
            parentElement.AppendChild(field);
        }
Example #2
0
        private static IList <FieldObject> FindChildrenFields(FieldObject field, IList <FieldObject> fieldList)
        {
            IList <FieldObject> childrenFields = new List <FieldObject>();

            foreach (FieldObject currentField in fieldList)
            {
                if (currentField.GetParent() != null && currentField.GetParent().GetName().EqualsIgnoreCase(field.GetName(
                                                                                                                )))
                {
                    childrenFields.Add(currentField);
                }
            }
            return(childrenFields);
        }