Example #1
0
        /// <summary>
        /// Creates the related business object from XML element.
        /// </summary>
        /// <param name="element">Xml element from which to create the <see cref="IBusinessObject"/>.</param>
        /// <param name="relatedObjectType">Type of the related object.</param>
        /// <returns>Related object.</returns>
        public static IBusinessObject CreateRelatedBusinessObjectFromXmlElement(XElement element, BusinessObjectType relatedObjectType)
        {
            if (relatedObjectType == BusinessObjectType.CommercialDocumentLine)
            {
                CommercialDocumentLine line = new CommercialDocumentLine(null);
                line.Deserialize(element);
                return(line);
            }
            else if (relatedObjectType == BusinessObjectType.WarehouseDocumentLine)
            {
                WarehouseDocumentLine line = new WarehouseDocumentLine(null);
                line.Deserialize(element);
                return(line);
            }
            else if (relatedObjectType == BusinessObjectType.Payment)
            {
                Payment pt = new Payment(null);
                pt.Deserialize(element);
                return(pt);
            }
            else
            {
                Mapper m = Mapper.GetMapperForSpecifiedBusinessObjectType(relatedObjectType);

                return(m.ConvertToBusinessObject(element, null));
            }
        }
        /// <summary>
        /// Recursively creates new children (BusinessObjects) and loads settings from provided xml.
        /// </summary>
        /// <param name="element">Xml element to attach.</param>
        public override void Deserialize(XElement element)
        {
            base.Deserialize(element);

            this.RelatedLine = null;

            if (element.Element("relatedLine") != null && this.Parent.Parent != null)
            {
                if (this.Parent.Parent.BOType == BusinessObjectType.CommercialDocument)
                {
                    WarehouseDocumentLine line = new WarehouseDocumentLine(null);
                    line.Deserialize(element.Element("relatedLine").Element("line"));
                    this.RelatedLine = line;
                }
                else
                {
                    CommercialDocumentLine line = new CommercialDocumentLine(null);
                    line.Deserialize(element.Element("relatedLine").Element("line"));
                    this.RelatedLine = line;
                }
            }
        }