npoi

Форк
0
/
StreamWriterExtensions.cs 
65 строк · 1.7 Кб
1
using System.IO;
2
using System.Runtime.CompilerServices;
3

4
namespace NPOI.OpenXmlFormats;
5

6
internal static class StreamWriterExtensions
7
{
8
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
9
    public static void WriteAttribute(this StreamWriter sw, string name, string value)
10
    {
11
        sw.Write(" ");
12
        sw.Write(name);
13
        sw.Write("=\"");
14
        sw.Write(value);
15
        sw.Write("\"");
16
    }
17

18
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
19
    public static void WriteAttribute(this StreamWriter sw, string name, int value)
20
    {
21
        sw.Write(" ");
22
        sw.Write(name);
23
        sw.Write("=\"");
24
        sw.Write(value);
25
        sw.Write("\"");
26
    }
27

28
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
29
    public static void WriteBooleanAttribute(this StreamWriter sw, string name, bool value)
30
    {
31
        sw.Write(" ");
32
        sw.Write(name);
33
        sw.Write("=\"");
34
        sw.Write(value ? 1 : 0);
35
        sw.Write("\"");
36
    }
37

38
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
39
    public static void WriteElementAndContent(this StreamWriter sw, string name, string value)
40
    {
41
        sw.Write("<");
42
        sw.Write(name);
43
        sw.Write(">");
44
        sw.Write(value);
45
        sw.Write("</");
46
        sw.Write(name);
47
        sw.Write(">");
48
    }
49

50
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
51
    public static void WriteEndElement(this StreamWriter sw, string name)
52
    {
53
        sw.Write("</");
54
        sw.Write(name);
55
        sw.Write(">");
56
    }
57

58
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
59
    public static void WriteEndW(this StreamWriter sw, string nodeName)
60
    {
61
        sw.Write("</w:");
62
        sw.Write(nodeName);
63
        sw.Write(">");
64
    }
65
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.