npoi
65 строк · 1.7 Кб
1using System.IO;2using System.Runtime.CompilerServices;3
4namespace NPOI.OpenXmlFormats;5
6internal static class StreamWriterExtensions7{
8[MethodImpl(MethodImplOptions.AggressiveInlining)]9public static void WriteAttribute(this StreamWriter sw, string name, string value)10{11sw.Write(" ");12sw.Write(name);13sw.Write("=\"");14sw.Write(value);15sw.Write("\"");16}17
18[MethodImpl(MethodImplOptions.AggressiveInlining)]19public static void WriteAttribute(this StreamWriter sw, string name, int value)20{21sw.Write(" ");22sw.Write(name);23sw.Write("=\"");24sw.Write(value);25sw.Write("\"");26}27
28[MethodImpl(MethodImplOptions.AggressiveInlining)]29public static void WriteBooleanAttribute(this StreamWriter sw, string name, bool value)30{31sw.Write(" ");32sw.Write(name);33sw.Write("=\"");34sw.Write(value ? 1 : 0);35sw.Write("\"");36}37
38[MethodImpl(MethodImplOptions.AggressiveInlining)]39public static void WriteElementAndContent(this StreamWriter sw, string name, string value)40{41sw.Write("<");42sw.Write(name);43sw.Write(">");44sw.Write(value);45sw.Write("</");46sw.Write(name);47sw.Write(">");48}49
50[MethodImpl(MethodImplOptions.AggressiveInlining)]51public static void WriteEndElement(this StreamWriter sw, string name)52{53sw.Write("</");54sw.Write(name);55sw.Write(">");56}57
58[MethodImpl(MethodImplOptions.AggressiveInlining)]59public static void WriteEndW(this StreamWriter sw, string nodeName)60{61sw.Write("</w:");62sw.Write(nodeName);63sw.Write(">");64}65}