private void WriteTo(XContainer markupSource, Control targetControl) { targetControl.Controls.Add(new LiteralControl(markupSource.ToString())); }
public static void SaveWithPath(XContainer x, string path) { SaveWithPath(x.ToString(SaveOptions.OmitDuplicateNamespaces), path); }
private static bool RemoveEmptyPropertyElements(IDomainObjectDTORepository dtoRepos, DomainObjectDTO currentDto, XContainer rtElement) { var propertyElements = (rtElement.Element("CmObject") != null) ? rtElement.Elements().Elements() // Two levels for old stuff before DM15 : rtElement.Elements(); // ToArray is required or Remove will end loop early. var emptyPropertyElements = (propertyElements.Where(propertyElement => !propertyElement.HasAttributes && !propertyElement.HasElements)).ToArray(); foreach (var emptyPropertyElement in emptyPropertyElements) { emptyPropertyElement.Remove(); } // Notify of update, if it changed. var results = false; if (emptyPropertyElements.Any()) { UpdateDTO(dtoRepos, currentDto, rtElement.ToString()); results = true; } return results; }
/// <summary> /// Instantiates ViewTransactionResponse class. /// </summary> /// <param name="xml"> /// View transaction operation response in XML format. /// </param> /// <returns> /// A <see cref="ViewTransactionResponse"/> object. /// </returns> public static ViewTransactionResponse FromXml(XContainer xml) { ViewTransactionResponse response = new ViewTransactionResponse() { MerchantId = xml.Element(MerchantIdNodeName).Value.Trim() }; string status = xml.Element(StatusNodeName).Value.Trim(); if (status.Equals(ActionStatus.Success)) { XElement transactionElement = xml.Element(TransactionNodeName); if (transactionElement != null) response.TransactionInfo = ParseSuccessTransaction(transactionElement); else throw new LiqPayException(ErrorCode.ResponseIsNotWellFormed, "Transaction element is not found in the response.", xml.ToString()); } else response.TransactionInfo = ParseFailureTransaction(xml); return response; }