本文整理汇总了C#中System.Xml.Linq.XContainer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XContainer.ToString方法的具体用法?C# XContainer.ToString怎么用?C# XContainer.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XContainer
的用法示例。
在下文中一共展示了XContainer.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
private void WriteTo(XContainer markupSource, Control targetControl)
{
targetControl.Controls.Add(new LiteralControl(markupSource.ToString()));
}
示例2: SaveWithPath
public static void SaveWithPath(XContainer x, string path)
{
SaveWithPath(x.ToString(SaveOptions.OmitDuplicateNamespaces), path);
}
示例3: RemoveEmptyPropertyElements
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;
}
示例4: FromXml
/// <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;
}