@@ -14,14 +14,16 @@ public interface IClipboardWriter
14
14
void AppendString ( string formatName , string data ) ;
15
15
void AppendStream ( string formatName , MemoryStream stream ) ;
16
16
void Flush ( ) ;
17
- void AppendInfo < T > ( ColumnInfo [ ] columnInfos ,
18
- IEnumerable < T > exportableResults ,
19
- string titleFormat ,
20
- ClipboardWriterAppendingInformationFormat appendingInformationFormat ) where T : IExportable ;
17
+ void AppendInfo < T > ( ColumnInfo [ ] columnInfos ,
18
+ IEnumerable < IExportable > exportableResults ,
19
+ string titleFormat ,
20
+ ClipboardWriterAppendingInformationFormat appendingInformationFormat ) where T : IExportable ;
21
21
}
22
22
23
+ [ Flags ]
23
24
public enum ClipboardWriterAppendingInformationFormat
24
25
{
26
+ None = 0 ,
25
27
XmlSpreadsheetFormat = 1 << 0 ,
26
28
RtfFormat = 1 << 1 ,
27
29
HtmlFormat = 1 << 2 ,
@@ -77,14 +79,13 @@ public void Flush()
77
79
}
78
80
79
81
public void AppendInfo < T > ( ColumnInfo [ ] columnInfos ,
80
- IEnumerable < T > results ,
82
+ IEnumerable < IExportable > results ,
81
83
string title ,
82
84
ClipboardWriterAppendingInformationFormat appendingInformationFormat ) where T : IExportable
83
85
{
84
86
object [ ] [ ] resultsAsArray = results . Select ( result => result . ToArray ( ) ) . ToArray ( ) ;
85
87
86
- var includeXmlSpreadsheetFormat = ( appendingInformationFormat & ClipboardWriterAppendingInformationFormat . XmlSpreadsheetFormat ) == ClipboardWriterAppendingInformationFormat . XmlSpreadsheetFormat ;
87
- if ( includeXmlSpreadsheetFormat )
88
+ if ( appendingInformationFormat . HasFlag ( ClipboardWriterAppendingInformationFormat . XmlSpreadsheetFormat ) )
88
89
{
89
90
const string xmlSpreadsheetDataFormat = "XML Spreadsheet" ;
90
91
using ( var stream = ExportFormatter . XmlSpreadsheetNew ( resultsAsArray , title , columnInfos ) )
@@ -93,26 +94,22 @@ public void AppendInfo<T>(ColumnInfo[] columnInfos,
93
94
}
94
95
}
95
96
96
- var includeRtfFormat = ( appendingInformationFormat & ClipboardWriterAppendingInformationFormat . RtfFormat ) == ClipboardWriterAppendingInformationFormat . RtfFormat ;
97
- if ( includeRtfFormat )
97
+ if ( appendingInformationFormat . HasFlag ( ClipboardWriterAppendingInformationFormat . RtfFormat ) )
98
98
{
99
99
AppendString ( DataFormats . Rtf , ExportFormatter . RTF ( resultsAsArray , title ) ) ;
100
100
}
101
101
102
- var includeHtmlFormat = ( appendingInformationFormat & ClipboardWriterAppendingInformationFormat . HtmlFormat ) == ClipboardWriterAppendingInformationFormat . HtmlFormat ;
103
- if ( includeHtmlFormat )
102
+ if ( appendingInformationFormat . HasFlag ( ClipboardWriterAppendingInformationFormat . HtmlFormat ) )
104
103
{
105
104
AppendString ( DataFormats . Html , ExportFormatter . HtmlClipboardFragment ( resultsAsArray , title , columnInfos ) ) ;
106
105
}
107
106
108
- var includeCsvFormat = ( appendingInformationFormat & ClipboardWriterAppendingInformationFormat . CsvFormat ) == ClipboardWriterAppendingInformationFormat . CsvFormat ;
109
- if ( includeCsvFormat )
107
+ if ( appendingInformationFormat . HasFlag ( ClipboardWriterAppendingInformationFormat . CsvFormat ) )
110
108
{
111
109
AppendString ( DataFormats . CommaSeparatedValue , ExportFormatter . Csv ( resultsAsArray , title , columnInfos ) ) ;
112
110
}
113
111
114
- var includeUnicodeFormat = ( appendingInformationFormat & ClipboardWriterAppendingInformationFormat . UnicodeFormat ) == ClipboardWriterAppendingInformationFormat . UnicodeFormat ;
115
- if ( includeUnicodeFormat && results is IEnumerable < IExportable > unicodeResults )
112
+ if ( appendingInformationFormat . HasFlag ( ClipboardWriterAppendingInformationFormat . UnicodeFormat ) && results is IEnumerable < IExportable > unicodeResults )
116
113
{
117
114
var unicodeTextFormat = title + Environment . NewLine + string . Join ( string . Empty , unicodeResults . Select ( result => result . ToClipboardString ( ) + Environment . NewLine ) . ToArray ( ) ) ;
118
115
AppendString ( DataFormats . UnicodeText , unicodeTextFormat ) ;
0 commit comments