Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

Extensions.cs

using System.Xml;

namespace Nop.Services.ExportImport;

/// 
/// Extensions
/// 
public static partial class Extensions
{
    /// 
    /// Write string async
    /// 
    /// XML writer
    /// Node name
    /// Node value
    /// Ignore
    /// Default value
    /// A task that represents the asynchronous operation
    public static async Task WriteStringAsync(this XmlWriter xmlWriter, string nodeName, object nodeValue, bool ignore = false, string defaulValue = "")
    {
        if (ignore)
            return;

        await xmlWriter.WriteElementStringAsync(null, nodeName, null, nodeValue?.ToString() ?? defaulValue);
    }

    /// 
    /// Write start element async
    /// 
    /// XML writer
    /// Node name
    /// A task that represents the asynchronous operation
    public static async Task WriteStartElementAsync(this XmlWriter xmlWriter, string nodeName)
    {
        await xmlWriter.WriteStartElementAsync(null, nodeName, null);
    }

    /// 
    /// Write attribute string async
    /// 
    /// XML writer
    /// Node name
    /// Node value
    /// Default value
    /// A task that represents the asynchronous operation
    public static async Task WriteAttributeStringAsync(this XmlWriter xmlWriter, string nodeName, object nodeValue, string defaulValue = "")
    {
        await xmlWriter.WriteAttributeStringAsync(null, nodeName, null, nodeValue?.ToString() ?? defaulValue);
    }

    /// 
    /// Write element string async
    /// 
    /// XML writer
    /// Node name
    /// Node value
    /// Default value
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the 
    /// 
    public static async Task WriteElementStringAsync(this XmlWriter xmlWriter, string nodeName, object nodeValue, string defaulValue = "")
    {
        await xmlWriter.WriteElementStringAsync(null, nodeName, null, nodeValue?.ToString() ?? defaulValue);
    }
}